• Vikas K
  • NEWBIE
  • 40 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 8
    Replies
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!




 
Hi All,

i have masterdetail relationship between quotes(parent) and quotelineitems(child)

and 

i also have lookup relationship between product(parent) and quotelineitems(child)

NOTE:there is no direct relationship between quotes and the product

REQUIREMENT:now i want to update a field in quotes object based on some condition in products object using Apex Trigger.

can anyone please let me know how can i proceed with this?
your help is much appreciated!
Hallo,

i have 20 records in quotes object(in production).
But i am not getting these 20 records in sandbox.

likewise i could not find records for many objects in sandbox
eventhough  they are present in production.

can some one help me out with this?
thanks in advance!
Hi,

i have 20 records in quotes object(in production).
But i am not getting these 20 records in sandbox.

likewise i could not find records for many objects in sandbox
eventhough  they are present in production.

can some one help me out with this?
thanks in advance!
Hi All ,
 i am stuck up at this point of code
 i cannot fetch the data of the column with a particular record type 

list<product2> p = [select id,name,Gegenkonto__c from product2 where RecordType='Produkte Vertrieb'];

error:
Gegenkonto__c from product2 where RecordType='Produkte Vertrieb' ^ ERROR at Row:1:Column:50 No such column 'RecordType' on entity 'Product2'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

thanks in advance
hallo All,  

when i try to execute the following query in sandbox

list<product> p = [select Name,type from Product];
system.debug(p);


i have records in the products object with name and type as columns..but when i try to fetch those records i am getting error  Invalid type: product

 Can you plz help me out in debugging this plz?
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!




 
Hi All,

i have masterdetail relationship between quotes(parent) and quotelineitems(child)

and 

i also have lookup relationship between product(parent) and quotelineitems(child)

NOTE:there is no direct relationship between quotes and the product

REQUIREMENT:now i want to update a field in quotes object based on some condition in products object using Apex Trigger.

can anyone please let me know how can i proceed with this?
your help is much appreciated!
Hallo,

i have 20 records in quotes object(in production).
But i am not getting these 20 records in sandbox.

likewise i could not find records for many objects in sandbox
eventhough  they are present in production.

can some one help me out with this?
thanks in advance!
Hi All ,
 i am stuck up at this point of code
 i cannot fetch the data of the column with a particular record type 

list<product2> p = [select id,name,Gegenkonto__c from product2 where RecordType='Produkte Vertrieb'];

error:
Gegenkonto__c from product2 where RecordType='Produkte Vertrieb' ^ ERROR at Row:1:Column:50 No such column 'RecordType' on entity 'Product2'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

thanks in advance
hallo All,  

when i try to execute the following query in sandbox

list<product> p = [select Name,type from Product];
system.debug(p);


i have records in the products object with name and type as columns..but when i try to fetch those records i am getting error  Invalid type: product

 Can you plz help me out in debugging this plz?