You need to sign in to do that
Don't have an account?
Trigger - Update Standard Object when (after Update) on Custom Object, pass 1 field value
Hello community,
I need to update a custom field in my standard Contact, that fires after a different, Custom Object is updated, validated by a lookup relationship. (The Custom Object has the Contact, and Contact's Account, listed as Lookups)
I've tried to write a trigger that passes the field value from my Custom Object to the Contact, but I keep getting a variety of errors - the most recent of which has stumped me. The end goal is to update Passing__c from Passing_Field__c. At the moment, the system does not recognize
p.Passing_Field__c
As a variable, which leads me to assume I'm not identifying the fields correctly to begin with. Is there a better way to do what I'm trying to accomplish here?
trigger ContactUpdater on Custom_Object_Name__c (after update) { List<Contact> updatedContacts = new List<Contact>(); Set<Id> ObjectIds = new Set<Id>(); Set<String> ObjectCont = new Set<String>(); Set<Boolean> ObjectActive = new Set<Boolean>(); Set<String> ObjectPass = new Set<String>(); for(Custom_Object_Name__c p : trigger.new){ If(p.Active__c == true){ ObjectIds.add(p.Id); ObjectCont.add(p.Contact__c); ObjectActive.add(p.Active__c); ObjectPass.add(p.Passing_Field__c); } } try{ for(Contact c : [SELECT Id, Passing__c FROM Contact WHERE (AccountId IN (Select Account__c from Custom_Object_Name__c )) AND ObjectActive = true]) { set(c.Passing__c = p.Passing_Field__c); c.FieldToUpdate = c.Passing__c; updatedContacts.add(c); } update updatedContacts; } catch(exception e){ throw e; }
*Notes: Active_c is a checkbox. Passing_c and Passing_Field__c are both text boxes.*
Hey,
Your variable 'p' is available only for the below block of code.
Thanks,
Anoop Asok
Hi
I am new to trigger can any help me out from this..........
Update Trigger on Custom object based on end user selection check box allowing the information to be inserted into another Custom object
Event is an Custom Object and
attended is Checkbox is an customm fileld for Event Object
So when a user selcted a checkbox with Attended the reocrd is saved in the Data Base .
My Reuirement is we nned to pull data using soql whoever selected the check box checked and move that data to be Inserted into another Custom Object name Contact_Event
There is no relation ship between these two Objects Event and Conatct_event both are Custom Objects.
Conatct_Event is a Junction Object and it has MasterDetail Realation Ship with Contact and Recurting Registration Objects