1

I am looking for an approach that when a user profile (e.g. Office Administrator) creates a new account and the administrator must assign another user (e.g. Account Manager) as the Account Owner when the administrator tries to save the record. Is it possible to do this? If so, what's the approach? I tried to look for the field security, or layout but it doesn't allow the administrator to change the Account Owner when try to create a new account.

1

Assuming the names you mention in your question are profile names, this code will automatically change the owner when the Account is inserted for 'Office Administrator' profile users to a 'Account Manager' profile user:

trigger AccountBeforeInsert on Account (before insert) {
    Id oaId = [select Id from Profile where Name = 'Office Administrator'].Id;
    if (UserInfo.getProfileId() == oaId) {
        Id amId = [select Id from Profile where Name = 'Account Manager'].Id;
        User[] users = [select Id from User where ProfileId = :amId and IsActive = true];
        // Need to pick one of the Users; this is arbitrarily just taking the first
        Id uId = users[0].Id;
        for (Account account : Trigger.new) {
            account.OwnerId = uId;
        }
    }
}
| improve this answer | |
0

Use account triggers to do that. You can create custom setting to map newly created account to user who should be owner (based on some value in your account).

You can also create flow for administrator to create new account (I am not 100% sure - but I think this should allow him to change owner).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.