
Hi Everyone,
I've created a simpletrigger that creates a new record of custom object: Hosted_PBX_Deployment__c when a new Opportunity is created.Now I need to set a value to a fiield: Rack_4_19_two_post_Qty__c in custom object that depends on a value of an Account field: All_Network_Devices_Qty__cso if Account.All_Network_Devices_Qty__c <=11 then Rack_4_19_two_post_Qty__c =1
what is the best way to reffer to an Account field from Hosted_PBX_Deployment__c trigger?
this is my trigger:trigger AutoCreateHPBXdeployment on Opportunity (after insert) {List<Hosted_PBX_Deployment__c> newHPBX = new List<Hosted_PBX_Deployment__c>(); for (Opportunity opp : Trigger.new) { if(opp.Hosted_PBX__c=='Yes'){ Hosted_PBX_Deployment__c hpbx = new Hosted_PBX_Deployment__c(); hpbx.Opportunity__c = opp.Id; hpbx.Opportunity_Account__c = opp.AccountId; newHPBX.add(hpbx); } } insert newHPBX;}Thank you!4 个回答
@Serghei Sleptov - Yes..using set will be better approach.@Krishnakumari - Thanks for bringing up process builder, Certainly that would be easy and OOB. But the original Question was asked for trigger...--Thanks,Prashant