You need to sign in to do that
Don't have an account?

Trigger to update account number using user object
for (User use : Trigger.new) {
String accid = use.AccountId;
List<Account> account = [SELECT AccountNumber FROM Account WHERE Primary_Id__c = :accid];
if(account != null && account.size()>0)
use.Primary_id__c = account[0].AccountNumber;
}
}
String accid = use.AccountId;
List<Account> account = [SELECT AccountNumber FROM Account WHERE Primary_Id__c = :accid];
if(account != null && account.size()>0)
use.Primary_id__c = account[0].AccountNumber;
}
}
Try this Isaac Sean
If the 'AccountId' field in User is a lookup field, then you can change the 'Primary Id' to a Formula field, which gets the 'Account Number' value from the Account lookup. This will prevent the need to update all the old User records which may have blank 'Primary Id' field.
Best Regards.