+ Start a Discussion
cedgcedg 

update erases a value set by trigger

Hi,

 

i've an object Registration for events, with lookup field to itself (one parent registration and some children registrations) and a field Contact__c to the Contacts.

 

When inserting the registrations, i have a trigger (before insert) checking if i can link them to existing Contacts or if i have to create new Contacts (based on email in the Registration form).

 

After inserting the parent and children registrations, the controller of my page sets the Status__c to a new value so as to fire a workflow rule and to generate the membercards with EmailTemplate. I do the update after all inserts (parent and children) so as to send one single mail with all the membership cards of these registrations. Problem is when updating  the Status__c of my registration, the Contact__c doesn't contain the value set by the trigger and so erase the Contact__c of the registration.

 

I can of course reload my Registration before updating the status, but it means one more SOQL statement.

 

Is there a way to avoid this SOQL statement without having the value of Contact erased ?

 

Thanks for your help

Ced

Best Answer chosen by Admin (Salesforce Developers) 
Damien_Damien_

Nope, you must run that SOQL in order to get the new updated values.  It is only 1 more query and so should be nothing to bother you too much.  Does this single SOQL statement cause you trouble?  Or were you just trying to eliminate a single query?

All Answers

Damien_Damien_

Nope, you must run that SOQL in order to get the new updated values.  It is only 1 more query and so should be nothing to bother you too much.  Does this single SOQL statement cause you trouble?  Or were you just trying to eliminate a single query?

This was selected as the best answer
cedgcedg

Hi Damien,

 

no real trouble, i just wanted to be sure there is no better way and that i'm not busy with useless SOQL.

 

thanks for the confirmation