function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

SOAP API: REGEX Validation Error on Textarea Field

I am using the SOAP API to upsert accounts. The BillingStreet textarea field is giving me problems.
There is a validation rule on the BillingStreet field in SFDC. The validation rule ensures that only 4 address lines are in the field and each line is 40 characters or less. Here is the validation formula:
REGEX(BillingStreet, "(.){0,40}"),
REGEX(BillingStreet, "(.){0,40}\r\n(.){0,40}"),
REGEX(BillingStreet, "(.){0,40}\r\n(.){0,40}\r\n(.){0,40}"),
REGEX(BillingStreet, "(.){0,40}\r\n(.){0,40}\r\n(.){0,40}\r\n(.){0,40}")

The validation works fine when maintaining data in SFDC. It allows up to 4 lines in the field each at 40 characters or less.

I am upserting account data using the SFDC SOAP API and setting the BillingStreet field as follows:
Account.BillingStreet = "123 Main St." (upserts without error with validation rule active)

However, this is what is giving me grief:

Account.BillingStreet = "123 Main St.\r\nPO Box 123"

If I make the validation rule for BillingStreet inactive and upsert the account data, there are no issues. The BillingStreet shows 2 lines in the textarea field as it should.
When the validation rule is active, the upsert fails with the Validation rule error message.

Can anyone tell me how I need to format the BillingStreet value so that it passes the validation rule?

Giorgio PorroGiorgio Porro


I know this is an old post, but do you recall if you got a solution on this?
I'm having a very similar issue.
Same formula you have (I need my address to be at most 3 lines of 36 characters long).

It all works fine when I edit the Account on the UI.

However, when I update the account using a SOAP API post from another system, the rule always validates as TRUE, hence, throwing the error.
Is it possible that the SOAP API Post is done using an old API version that does not support REGEX? That's all I can think of

If you have any suggestions, please let me know, it would be greatly appreciated