• Niccole
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies

Hi there,

I am trying to trigger a new case to be created when a custom field (Quote Status) on my opportunity has the value "Quote Approval".  See screen shot for further field info, if needed.  

Since I am new to Apex and Triggers, I found and modified some code.  (Original Code found on https://developer.salesforce.com/forums/ForumsMain?id=906F0000000942YIAQ  (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000942YIAQ) )  My modified code is throwing an error message "Error: Compile Error: Invalid foreign key relationship: Opportunity.Quote_Status_v2__c at line 4 column 109".  When I deleted the "opp." from "opp.Quote_Status_v2__c", I then received the following error message "Error: Compile Error: Variable does not exist: Quote_Status_v2__c.equals at line 4 column 105".

Can someone tell me what I am doing wrong and how to fix it.  If it is possible to correct my trigger, I would greatly appreciate it :)!

My trigger:

trigger SEApproveRejectQuoteTaskCaseCreation on Opportunity (after insert,after update) {
        for (Opportunity opp: Trigger.New)
    { case newcase=new case();
         if((trigger.isInsert && (opp.Quote_Status_v2__c.equals('Quote Approval'))) || (trigger.isUpdate &&(opp.Quote_Status_v2__c.equals !=  Trigger.oldMap.get(opp.Id).Quote_Status_v2__c && opp.Quote_Status_v2__c.equals('Quote Approval'))))
         {
            system.debug('----------opp.Account---->'+opp.Account);
            newcase.Account=opp.Account;
            newcase.Opportunity__c=opp.Name;
            newcase.Subject='Approve / Reject Quote for '+opp.Name;
            newcase.Description='Quote approval is needed for '+opp.Name;
            newcase.Status='New';
            newcase.Origin='End User Request';
            newcase.Priority='Low';
            newcase.Task_Steps__c='1. Review Quote \n2. Approve / Reject Quote \n3. Complete case in Salesforce';
         }}}


User-added image

I have several fields on my Case object that I want to auto populate depending on certain conditions.  For the most part, I have my trigger set up to do what I want.  The issue I am running into is at the end of the trigger.  The field (c.Task_Steps__c) is a text field with the ability to have 255 characters.  Currently, how my trigger is written, it populates the text field with a horizontal list like such:

1. Review Quote  2. Approve / Reject Quote  3. Complete task in Salesforce

However, I want to populate this field with vertical list values so that it looks like the following:

  1. Review Quote
  2. Approve / Reject Quote
  3. Complete task in Salesforce

Is this even possible?  I am new to writing Apex and Triggers so any information / code modification would be greatly appreciated :)!

Code:

trigger SEApproveRejectQuote_assignment on Case (Before update)
{for (Case c: Trigger.new)
{if(c.Reason=='Approve / Reject Quote' && c.Status=='New')
{
c.Origin='End User Request';
c.Type='SE Task';
c.Subject='Approve / Reject Quote';
c.Description='Quote approval is needed';
c.Task_Steps__c='1. Review Quote  2. Approve / Reject Quote  3. Complete task in Salesforce';
             }}}

 

I am looking for help with automatically adding a person to an opportunity team.  We have a custom formula field "Lead Sales Engineer Assinged" that is populated with a Sales Engineer's name when a certain primary site (another custom picklist field) is selected.   What I am looking to do is to automatically add that person to the opportunity team when the opportunity is created and assign them with a team role of Lead Sales Engineer.  Any help will be greatly appriciated.  Also,  as I am new to Apex, if anyone can provide me with sample code that would be awesome :)!!

Hi there,

I am trying to trigger a new case to be created when a custom field (Quote Status) on my opportunity has the value "Quote Approval".  See screen shot for further field info, if needed.  

Since I am new to Apex and Triggers, I found and modified some code.  (Original Code found on https://developer.salesforce.com/forums/ForumsMain?id=906F0000000942YIAQ  (https://developer.salesforce.com/forums/ForumsMain?id=906F0000000942YIAQ) )  My modified code is throwing an error message "Error: Compile Error: Invalid foreign key relationship: Opportunity.Quote_Status_v2__c at line 4 column 109".  When I deleted the "opp." from "opp.Quote_Status_v2__c", I then received the following error message "Error: Compile Error: Variable does not exist: Quote_Status_v2__c.equals at line 4 column 105".

Can someone tell me what I am doing wrong and how to fix it.  If it is possible to correct my trigger, I would greatly appreciate it :)!

My trigger:

trigger SEApproveRejectQuoteTaskCaseCreation on Opportunity (after insert,after update) {
        for (Opportunity opp: Trigger.New)
    { case newcase=new case();
         if((trigger.isInsert && (opp.Quote_Status_v2__c.equals('Quote Approval'))) || (trigger.isUpdate &&(opp.Quote_Status_v2__c.equals !=  Trigger.oldMap.get(opp.Id).Quote_Status_v2__c && opp.Quote_Status_v2__c.equals('Quote Approval'))))
         {
            system.debug('----------opp.Account---->'+opp.Account);
            newcase.Account=opp.Account;
            newcase.Opportunity__c=opp.Name;
            newcase.Subject='Approve / Reject Quote for '+opp.Name;
            newcase.Description='Quote approval is needed for '+opp.Name;
            newcase.Status='New';
            newcase.Origin='End User Request';
            newcase.Priority='Low';
            newcase.Task_Steps__c='1. Review Quote \n2. Approve / Reject Quote \n3. Complete case in Salesforce';
         }}}


User-added image

I have several fields on my Case object that I want to auto populate depending on certain conditions.  For the most part, I have my trigger set up to do what I want.  The issue I am running into is at the end of the trigger.  The field (c.Task_Steps__c) is a text field with the ability to have 255 characters.  Currently, how my trigger is written, it populates the text field with a horizontal list like such:

1. Review Quote  2. Approve / Reject Quote  3. Complete task in Salesforce

However, I want to populate this field with vertical list values so that it looks like the following:

  1. Review Quote
  2. Approve / Reject Quote
  3. Complete task in Salesforce

Is this even possible?  I am new to writing Apex and Triggers so any information / code modification would be greatly appreciated :)!

Code:

trigger SEApproveRejectQuote_assignment on Case (Before update)
{for (Case c: Trigger.new)
{if(c.Reason=='Approve / Reject Quote' && c.Status=='New')
{
c.Origin='End User Request';
c.Type='SE Task';
c.Subject='Approve / Reject Quote';
c.Description='Quote approval is needed';
c.Task_Steps__c='1. Review Quote  2. Approve / Reject Quote  3. Complete task in Salesforce';
             }}}

 

I am looking for help with automatically adding a person to an opportunity team.  We have a custom formula field "Lead Sales Engineer Assinged" that is populated with a Sales Engineer's name when a certain primary site (another custom picklist field) is selected.   What I am looking to do is to automatically add that person to the opportunity team when the opportunity is created and assign them with a team role of Lead Sales Engineer.  Any help will be greatly appriciated.  Also,  as I am new to Apex, if anyone can provide me with sample code that would be awesome :)!!