You need to sign in to do that
Don't have an account?
mac admin
Trigger to updtae Status
Hi all,
I want to update the status field when an record is created in the 3rd object. Let say I have 3 objects A B and C. When a record is created in object C before inserting the record I want to check the email ID in the remaning objects A and B if the mail ID is matching with remaning two object i want show the flag symbool in those two objects and update the picklist in the object C. Can anyone help me over here.
Thanks in advance,
Regards,
mac.
I want to update the status field when an record is created in the 3rd object. Let say I have 3 objects A B and C. When a record is created in object C before inserting the record I want to check the email ID in the remaning objects A and B if the mail ID is matching with remaning two object i want show the flag symbool in those two objects and update the picklist in the object C. Can anyone help me over here.
Thanks in advance,
Regards,
mac.
Whats the relation here between the objects.
I think writing a after insert trigger would suffice, but the object C should have a lookup up to the objects A and B to refer them and check for the email and update the flag in those records
Hope it helps
RD
In my small change i want to update the status in the remaning two objects not in the object C. Can you help me over here.
For after insert trigger to pickup the other two records from objects A and B, atleast a lookup is needed in object C. i.e. two lookups one pointing to object A record and other pointing to object B record. so that the update on the records and checking the emails from A and B can be done and the object c record can be updated.
Do you have any such lookups?
check the below code..
trigger checkForAandB on objectC(After Insert)
{
// declare list of other 2 objects to update
List<objectA> existing_objA = new List<objectA>();
List<objectB> existing_objB = new List<objectB>();
Set<String> emails = new Set<String>(); // to keep all emails
for(objectC oC : Trigger.New)
{
// check for email and add in set variable
if(!String.IsBlank(oC.Email__c))
{
emails.add(oC.Email__c);
}
}
//check if emails are there
if(!emails.IsEmpty())
{
//query all obA records with Same email and map the status
for(objectA oA : [SLECT Id,Email__c,Status__c FROM objectA WHERE Email__c IN: emails])
{
oA.Status__c = 'Flag';
existing_objA.add(oA);
}
//query all obB records with Same email and map the status
for(objectB oB : [SLECT Id,Email__c,Status__c FROM objectB WHERE Email__c IN: emails])
{
oB.Status__c = 'Flag';
existing_objB.add(oB);
}
//Update those records
Update existing_objA;
Update existing_objB;
}
}
It's not updtaing the Status fields in the both object can you help me over here.
Thanks in advance.
Regards,
mac.
Please share the code..
Regards,
Vijaya Amarnath.
Can you help me over here.
Thanks in advance.
Regards,
mac.
Let me get you requirement. Suppose in Under Graduate record if you are entering a email ex: ug@gmail.com, then with the same email if foound any Lead/Inquiry Form Leads.. We need to update those 2 records.. Am I correct on your requirement?..
I have created the code as you mentioned but the fields are not updtaing. Can you help me over here.
Thanks in advance.
Regards,
mac.
Can you hlep me with query to update the fields.