You need to sign in to do that
Don't have an account?
BPeddle
Site Guest User, Trigger and Account Change
I have a trigger which works when I am logged in a regular user. If I am using the site guest user the same trigger executes but doesn't do everything.
In the trigger on Before Insert I create a dummy account and then try to assign to the new contact being created. I also try to run it after insert and it just seems to skip the changing of account without error.
The account is created in either case
This works when logged in and not with Guest Account:
if (Trigger.isBefore) { // get the business account record type (which is candidate) // RecordType NotPersonAccountRecordType = [select Id from RecordType where SobjectType = 'Account' and Name = 'Candidate']; // create new account for one to one record to the contact, type will be the business account from above Account newAccount = new Account(); newAccount.Name = 'TempAccount'; newAccount.OwnerId = Trigger.new[0].OwnerId; newAccount.RecordTypeId = NotPersonAccountRecordType.Id; insert newAccount; //iterate through Trigger.new and change the Contact to New Account Just Created for(Contact C : Trigger.new){ c.AccountId = newAccount.Id; } }
This also work using after insert
Wondering if this is just a limitation of the guest user account and being able to reassign it.