You need to sign in to do that
Don't have an account?

TRIGGER TO UPDATE A FIELD ON ONE OBJECT BASED ON FIELD CONDITION ON ANOTHER OBJECT
Hallo All,
I have masterdetail relationship between two objects quotes(parent) and quotelineitems(child)
REQUIREMENT: i am trying to create a trigger to update a field in quotes based on field condition in quotelineitems
NOTE: quotelineitems(child) also have lookup relationship with product(parent)
CODE:
trigger test2 on Quote (before insert)
{
if(trigger.isinsert && trigger.isbefore)
{
for(Quote q1:trigger.new)
{
list<quotelineitem> qli = [select id,Produktname__c,Gegenkonto_AGBP__c from quotelineitem where Gegenkonto_AGBP__c = '84000' or Gegenkonto_AGBP__c = '84001'];
list<quote> q = [select id,Name,Angebotsinhalt__c from quote where recordtype.name = 'angebot'];
if(qli.Gegenkonto_AGBP__c == '84000')
{
q.Angebotsinhalt__c = qli.Produktname__c;
}
else if(qli.Gegenkonto_AGBP__c == '84001')
{
q.Angebotsinhalt__c = 'produktion';
}
else
{
q.Angebotsinhalt__c = 'sonstiges';
}
}
}
}
ERRORS:
Variable does not exist: Gegenkonto_AGBP__c
Variable does not exist: Produktname__c
Variable does not exist: Angebotsinhalt__c
Variable does not exist: Gegenkonto_AGBP__c
Variable does not exist: Angebotsinhalt__c
Variable does not exist: Angebotsinhalt__c
but when i look at the objects metadata i have all the above mentioned fields but when i try to code i am getting the above errors.
quote object fields:
Angebotsinhalt__c(text field)
quotelineitem fields:
Produktname__c(text field)
Gegenkonto_AGBP__c(picklist field)
Can someone please let me know at which part of the code i have gone wrong so that i can rectify?
Thanks for your help!
I have masterdetail relationship between two objects quotes(parent) and quotelineitems(child)
REQUIREMENT: i am trying to create a trigger to update a field in quotes based on field condition in quotelineitems
NOTE: quotelineitems(child) also have lookup relationship with product(parent)
CODE:
trigger test2 on Quote (before insert)
{
if(trigger.isinsert && trigger.isbefore)
{
for(Quote q1:trigger.new)
{
list<quotelineitem> qli = [select id,Produktname__c,Gegenkonto_AGBP__c from quotelineitem where Gegenkonto_AGBP__c = '84000' or Gegenkonto_AGBP__c = '84001'];
list<quote> q = [select id,Name,Angebotsinhalt__c from quote where recordtype.name = 'angebot'];
if(qli.Gegenkonto_AGBP__c == '84000')
{
q.Angebotsinhalt__c = qli.Produktname__c;
}
else if(qli.Gegenkonto_AGBP__c == '84001')
{
q.Angebotsinhalt__c = 'produktion';
}
else
{
q.Angebotsinhalt__c = 'sonstiges';
}
}
}
}
ERRORS:
Variable does not exist: Gegenkonto_AGBP__c
Variable does not exist: Produktname__c
Variable does not exist: Angebotsinhalt__c
Variable does not exist: Gegenkonto_AGBP__c
Variable does not exist: Angebotsinhalt__c
Variable does not exist: Angebotsinhalt__c
but when i look at the objects metadata i have all the above mentioned fields but when i try to code i am getting the above errors.
quote object fields:
Angebotsinhalt__c(text field)
quotelineitem fields:
Produktname__c(text field)
Gegenkonto_AGBP__c(picklist field)
Can someone please let me know at which part of the code i have gone wrong so that i can rectify?
Thanks for your help!
Please let me know if this was helpful.
Thanks.
yes there is read access for the fields of quotelineitems Produktname__c(text field),Gegenkonto_AGBP__c(picklist field)
and there is both read and edit access for the field that i want to edit i.e Angebotsinhalt__c field of quote object
inspite of having the access i am getting that error