You need to sign in to do that
Don't have an account?
Associating two objects using a trigger
Hi,
I'm not a trained developer so please excuse me if this seems a bit obvious.
I have 2 custom ojects that are both related to Opportunity. Quote_Request__c (QER) and Quote__c (Q).
These are obviously related one to another. They both hold a field called Quote_Header_ID__c. When a quote is returned by our integration with our internal quoting system we would like to see to which QER the quote is related.
So: there is an additional field on the quote table called Quote_Estimate_Request__c which is a lookup relationship to the Quote_Request__c object.
Quote Header Ids in will be unique for the QER but there may be many quotes related.
So... What I did thus far:
trigger addQERassociation on Quote__c (before insert, before update) {
Decimal dQERid;
for (Quote__c q :Trigger.new)
{
dQERid= q.quote_header_id__c;
if(dQERid!= '')
{
for (List<Quote_Request__c> qer :[Select ID from Quote_Request__c qr where (qr.Quote_Header_ID__c = 123456)]) //dQERid)])
{
if(qer.Size() > 0)
{
q.Quote_Estimate_Request__c = qer[0];
}
}
}
}
}
The current issue is that I am getting a compile error: Error: Compile Error: Illegal assignment from SOBJECT:Quote_Request__c to Id at line 13 column 21
The other is that I cannot put the variable: dQERid into the select statement as it errors out with: Error: Compile Error: unexpected token: 'dQERid' at line 9 column 112 (Fixed: I added a colon to make :dQERid)
Does anyone have any advice? Please?
I did it and it works:
My changes are highlighted in red