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

Trigger query field
Hi,
our developer has created this trigger to check the owner of an account. Initialowner__C is a cusotm field and a text field. I searched everywhere but i am not sure from where we can get the initialowner__C field value.
Any idea?
our developer has created this trigger to check the owner of an account. Initialowner__C is a cusotm field and a text field. I searched everywhere but i am not sure from where we can get the initialowner__C field value.
Any idea?
trigger ownerchange on Account (before insert) { Account [] acc = Trigger.new.clone(); Profile pfs = [Select Id, name from Profile where id = :UserInfo.getProfileId()]; UserRole rls = null; if(UserInfo.getUserRoleId() != null) { rls = [Select Id, name from UserRole where id =:UserInfo.getUserRoleId() ]; } if(acc[0].InitialOwner__c!=null && ((rls != null && rls.name == 'Team') || pfs.name =='Manager')) { Trigger.new[0].Ownerid = Trigger.new[0].InitialOwner__c; } }
Fields in triggers are lazy loaded, so simply referencing them in code using the dot notation like on line 08 should just have the value in it.
The only complication here is, (for some reason?) you are cloningTrigger.new into a new array, so - off the top of my head - I don't actually know exactly if you will still get all the benefits of the lazy loading in the trigger context variables.
Does the clone of the account list get created by copy, or reference? Why do you need to clone trigger.new as you are just copying two fields over within that record I can't quite work out what you are hoping this trigger does at such a complicated level!
What s your error message.. then perhaps we can work on it..!
How do you create those accounts? Do you import them or create manually via Salesforce interface? I'll be honest with you this code is a liitle bit messy. I would assume that that field would be added to new account form layout and this is from where you can take that value. However without more info I'm not 100% sure.
I checked in my org and yes the initialowner was getting copied from custom clone buton.....................
But issue is, it is not working..it overrides the owner
My button code:
This is my full trigger. I did the Debug logs and found that the trigger runs but it skips the owner association. but it keep the status=active. so i am nto sure why it skips the owner association.