+ Start a Discussion
Hemalatha  ParuchuriHemalatha Paruchuri 

Auto update fields

I have 2 objects bp_c and mp_c.on mp_c lookup relation to bp_c.
bp_ c have (multiselect picklist) field called grouped field values like Medical,Dental,vision.
mp_c have (picklist) field medical values like eligible,waved,N/A
mp_c have (picklist) field Dental values like eligible,waved,N/A.

when ever i craeted or updated in bp__c  multiselect picklist value medical need to be changed values in mp__c medical defaultly N/A
when ever i craeted or updated in bp__c  multiselect picklist value medical need to be changed values in mp__c Dental  defaultly N/A
Navee RahulNavee Rahul
Hello Hemalatha,


you can achive the requirement by creating the trigger like below.

trigger UpdateStatus on bp_c(after insert,after update) {

   
    Set<ID> setaccId = new Set<ID>();
    for(bp_c acc : trigger.new)
        {

		if(acc.medical!='')
		{
			//Query mp__c table and update the Medical field
		mp__c holdermedical=[select Medical from mp__c where id=:acc.lookupid];
		holdermedical.medical='N/A';
		holdermedical update;

		}
         }
   
}
 where  holdermedical.medical  is a Picklist  (custom object)

.the above code is just a Idea and minimal sudo,wont work if implement the same.

mark correct, if this answer solves you'r problem.

Thanks
D Naveen Rahul.
Hemalatha  ParuchuriHemalatha Paruchuri
Hi Naveen Rahul.,

Thanks for replying back.

trigger Newupdate on Benefits_Program__c (After insert,after update) {
    Set<ID> setaccId = new Set<ID>();
    for(Benefits_Program__c acc : trigger.new)
        {

        if(acc.Medical_Products_Offered__c!='Null')
        {
            //Query mp__c table and update the Medical field
 Member_Profile__c holdermedical=[select I_Medical_Pipeline__c from Member_Profile__c where id in:acc.Benefits_Program__c];
 holdermedical.I_Medical_Pipeline__c='N/A';
         update holdermedical;
        }
        }
   }

i got error like this ------Invalid field Benefits_Program__c for SObject Benefits_Program__c