Regex를 사용하지 않는 이유는 제대로 작동하지 않기 때문입니다. 대신 수식을 사용하여 유효성 검사를 수행하는지 확인했습니다. 우리는 두 줄의 한계가 있기 때문에 이것을 먼 길로하는 것은 그리 나쁘지 않았습니다.
AND(
IF(
//Look for a line break. If there is one, split and compare lengths separately.
FIND(MID($Setup.Global__c.CLRF__c ,3,1), BillingStreet) > 0
,
IF(
//If the first line is over the limit, return true to trigger validation.
LEN(LEFT(BillingStreet, FIND(MID($Setup.Global__c.CLRF__c ,3,1), BillingStreet)-2))>41
,
TRUE
,
//If first line is fine, check second line and since this is a condition, it will return true/false automatically.
LEN(MID(BillingStreet, FIND(MID($Setup.Global__c.CLRF__c ,3,1), BillingStreet)+1,LEN(BillingStreet))) > 41
)
,
//If there is no line break (one line) check the total length.
LEN(BillingStreet) > 41
)
,
//There is a validation for having more than 2 lines. Without this, it will combine lines 2 and above and check that length and will be confusing to users when it's > 41.
NOT(REGEX(BillingStreet , '(.*\r?\n.*){2,}'))
,
//Ignore this rule if the user has this flag active. Useful for bulk updating and don't have to worry about import errors.
$User.Bypass_Validation__c = False
)
이 조각 MID($Setup.Global__c.CLRF__c ,3,1)
은 Salesforce의 줄 바꿈을 나타냅니다. 그것이 작동하는 방법을 발견했다 find line break in formula field. 나는 Regex를 사용하는 것을 좋아했을 것이다. 그러나 당신이 나에게 묻는다면 그것은 작동하지 않는다. 위의 코드 에서처럼 2 개 이상의 행을 검사하는 경우를 제외하고.
'^ $'앵커로 시도 했습니까? – ctwheels
캐리지 리턴 또는 라인 피드가 BillingStreet에 몰래 들어가서 정규식을 만들지 못하나요? . does not match \ n – sniperd
예를 들어 링크 한 줄에 표시하고 싶습니다. 예는 정확하지만 입력란에 같은 텍스트를 넣어도 유효성 검사가 실행되지 않습니다. Salesforce의 필드는 텍스트 영역이지만 QuickBooks와 동기화되면 각 행을 구분하여 각 행의 문자 길이가 41자인 5 개의 주소 블록 행 중 하나에 배치합니다. 나는^^ 앵커를 시도 할 것이다. – icebird76