You need to sign in to do that
Don't have an account?
Ludivine
Trigger to automatic copy picklist values
Hello !
I have begun a trigger to copy on the Actions page (Opportunity page) ,the picklist values of 3 fields from the Account related list
But I meet troubles to do the mapping.
I can't map the AccountId field from Oppty(Actions), I have the following error :
Error: Compile Error: Illegal assignment from Schema.SObjectField to String at line 30 column 10
Here here my code... I have done my best using other existing triggers in my org but it is probably wrong...
Trigger UpdateIndustrySegmentSubSegment on Opportunity (Before insert,Before Update) { // Initialise ID maps for related sObjects map<Id, Account> mapAccount = new map<Id, Account>(); // Fill the Id -- > sObject maps for Accounts for(Account[] arrAccount: [ select Id, Name,industry__c,segment__c,sub_segment__c from Account where id in :mapAccount.keySet() ]) { for(Account sAccount : arrAccount) { mapAccount.put(sAccount.Id, sAccount); } } for(Opportunity sOppty : trigger.new) { Account thisAccount = mapAccount.get(sOppty.Account.Id); if( sOppty.Business_group__c == 'Amcor Flexibles Europe & Americas' && //thisAccount.industry__c != null && sOppty.RecordTypeId != '012200000002HdgAAE') {sOppty.industry__c = Account.industry__c; sOppty.segment__c = Account.segment__c; sOppty.sub_segment__c = Account.sub_segment__c;} } }
Thanks a lot for your help
Hi all,
For those who are working night and day like me on these kind of simple isuues , I am glad to write below a nice present e.g Ze Solution :)
All Answers
Try wrapping your three assignments at the bottom in a string.valueOf()
Thanks for your reply, I have made the changes.
Do you know how I could map the AccountId field from opportunity to Account.ID related list in my trigger because in my code it is not good :(
Many thanks
Hi all,
For those who are working night and day like me on these kind of simple isuues , I am glad to write below a nice present e.g Ze Solution :)