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

Account billing street not populating from custom object?

We have a custom Bill To object that populates address information onto the account. We have this snippet of code -



          a.BillingStreet = btst.Street_1__c!=null?btst.Street_1__c:''+' '+btst.Street_2__c!=null?btst.Street_2__c:'';


It is working correctly for Street 1, but Street 2 is not copying from Bill To to the Account. What could be the problem?


It is not a bug, but I would probably not add a space in between your two streets unless the second and the first streets are both non-null. 


As written, you will always add a space at the end of a non-null street 1, even if street 2 is null.

Also, you will always add a space before street 2 even if street 1 is null.


More importantly, have you tried setting it up as two statements to determine if that will work:


a.BillingStreet = btst.Street_1__c!=null?btst.Street_1__c:'';
a.BillingStreing += btst.Street_2__c!=null?' ' + btst.Street_2__c:'';