You need to sign in to do that
Don't have an account?
Mdex Centre-Ville
Update field after insert
Hi.
I did a very simple Trigger to update 2 custom field
First is a custom lookup field that lead to contact: lookup_contact__c
Second is the subject field that is supposed to be populated from 2 custom field
trigger Updatelookup on Event (before insert, before update){
for (event u : Trigger.new){
u.lookup_contact__c = u.WhoId;
u.Subject = u.Nom_formate__c + u.Raison_visite_formate__c;
}
}
The trigger by himself is working well exept that I'll need to run it after insert because WhoID is populated after the trigger run so .. this informations is always missing exept if i make a manual update.
the problem is if I say after insert, I have an error message because I con only use before insert.
Can you help me with that ? (Process builder is not working at all for that because it also run .. befaore whoID is populated :( )
I did a very simple Trigger to update 2 custom field
First is a custom lookup field that lead to contact: lookup_contact__c
Second is the subject field that is supposed to be populated from 2 custom field
trigger Updatelookup on Event (before insert, before update){
for (event u : Trigger.new){
u.lookup_contact__c = u.WhoId;
u.Subject = u.Nom_formate__c + u.Raison_visite_formate__c;
}
}
The trigger by himself is working well exept that I'll need to run it after insert because WhoID is populated after the trigger run so .. this informations is always missing exept if i make a manual update.
the problem is if I say after insert, I have an error message because I con only use before insert.
Can you help me with that ? (Process builder is not working at all for that because it also run .. befaore whoID is populated :( )
https://help.salesforce.com/HTViewHelpDoc?id=activities_shared_enabling.htm
Searching around also found this: https://developer.salesforce.com/forums/ForumsMain?id=906F000000095HTIAY
I guess someone had a future call kick off on an after insert which handled the update?
"Allow Users to Relate Multiple Contacts to Tasks and Events" is enable yes so, You say that I should ask the support tean to desable it ?
Yes, the popic explain very well my problem.
the answer seems to be:
-------------------------
Hello Ben,
The workaround I implemented was to have the trigger check to see if WhoId and WhatId were both NULL. If so, the trigger would pass the task Ids to an @future method that would then check to see if WhoId or WhatId was populated.
Let me know if I was not clear in the explanation.
Thanks,
Eric
--------------------
But Ihave no ideas about how to do it :(
thx for your help (Now, I know that even if I have rule after insert, I'll have the same problem)
Trigger:
Class that has the future call:
if this helps, consider marking it the valid answer?