Our App syncs to Salesforce objects using a Listing ID field that matches Account or Opportunity or Case Number but the field needs to be set to an External ID and those number fields do not allow that. So,
We added a custom field to Account record that we configured to operate as External ID And we want the value in that field to be copied from the 18 digit Account Id
We've tried adding a trigger to
trigger CopyAccountNumberToCustomField on Account (before insert) {
for (Account acc : Trigger.new) {
// Check if Account Number is not null or empty
if (String.isNotBlank(acc.AccountNumber)) {
acc.Listing_ID__c = acc.AccountNumber; // Copy Account Number to Listing_ID custom field
}
}
}
And we tried adding a trigger after insert
trigger CopyAccountNumberToCustomField on Account (after update) {
for (Account acc : Trigger.new) {
// Check if Account Number is not null or empty
if (String.isNotBlank(acc.AccountNumber)) {
acc.Listing_ID__c = acc.AccountNumber; // Copy Account Number to Listing_ID custom field
}
}
}
neither one worked
Any tips on how to copy an Account Number into a custom text field on Account record create?
after update
a typo, or do you really have it asafter update
and notafter insert
?after update
andafter insert
neither one works.AccountNumber
in whatever code/process you're using to create Accounts?AccountNumber
is not an auto-number field, so it will be null (blank) unless you populate it.