• Frank Jordan
  • NEWBIE
  • 40 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
I have the following code and I am receiving this error: Invalid field Update_Contract_Request_Summary__c for SObject Opportunity. Does anyone know how to fix this? 
 
public class UpdateRequestContractExttwo_ecsg   {
    private final Opportunity opp;
     
    Opportunity tempOpp ;
   
    public UpdateRequestContractExttwo_ecsg(ApexPages.StandardController stdController) {
        this.opp = (Opportunity)stdController.getRecord();
        tempOpp = [select id ,ContactVerified__c,Contract_Specialist_Assigned__c, type,
                   Master_Agreement_Number__c,Current_Contract_Status__c,Date_Assigned_to_Specialist__c,
                   Date_Contract_Requested__c from Opportunity where id=: stdController.getId()];
        system.debug('--------------opp.id----------------'+opp.id );
    }
 
   
   //this is page load 
   public PageReference pageLoad(){
    
         PageReference oppPage = new ApexPages.StandardController(opp).view();
           oppPage.setRedirect(true);
            
      if(opp.Contract_Request_Date__c == null){ 
           ApexPages.Message errorMsg = new ApexPages.Message(ApexPages.Severity.Error,'A contract has not be requested for this Oppotunity yet');
           ApexPages.addMessage(errorMsg);
           return null ;
      
      }else if(Opp.Update_Contract_Request_Summary__c == null || Opp.Update_Contract_Request_Summary__c =='')
           {
                 ApexPages.Message errorMsg = new ApexPages.Message(ApexPages.Severity.Error,'Please enter Updated Contract Request Summary.');
                 ApexPages.addMessage(errorMsg);
                 return null ;
          }
         else
          {
              // set All associated ARs to Update from Oportunity
              List<Agreement_Request__c> AgreementRequests_to_update=new List<Agreement_Request__c>();
              AgreementRequests_to_update=[Select id,Request_Status__c,Opportunity__c from Agreement_Request__c where Opportunity__c=:opp.Id ];
              if(AgreementRequests_to_update.size()>0)
              {
                  for (Agreement_Request__c ar:AgreementRequests_to_update)
                  {
                      ar.Request_Status__c='Update from Opportunity';
                      ar.Updated_Agreement_Summary__c=opp.Updated_Agreement_Summary__c;
                  }
                 update AgreementRequests_to_update;
              }
                
              
           return oppPage;
         }
   }
   
}

 
I have the below class that updates the status on an agreement request and it's associated agreeemnt (parent record). It is giving me the below error and I can't figure out why. This is my first time using 'try' so im not sure if i am using it correctly or not. Thanks in advance for the help. 
 
public class SubmitUpdateToLegal {
 
try{
    // Query for the agreement request, which has been associated with an agreement.
    Agreement Request queriedAR = [SELECT Agreement_Request__c.Master_Agreement__c 
                              FROM Agreement_Request__c 
                              WHERE Master_Agreement__c != ''
                              ];

    // Update the agreement requests's status
    queriedAR.Status__c = 'Update from Opportunity';

    // Update the related agreement's status
    queriedAR.APTS_Agreement.Apttus__Status__c = 'Update From Opportunity	';

    // Make two separate calls 
    // 1. This call is to update the agreement request's status.
    update queriedAR;
    // 2. This call is to update the related agreement's status field.
    update queriedAR.APTS_Agreement; 
} catch(Exception e) {
    System.debug('An unexpected error has occurred: ' + e.getMessage());
}
}

 
I have the following class and visualforce page created, so when the button is pressed, the record owner is updated. I would like to add this button to the detail page like the button below. Can anyone help? 

User-added image

Class: 
public class classSubmitToLegal {

    public Agreement_Request__c a{get;set;}
    public classSubmitToLegal() {
     a = new Agreement_Request__c ();
     a = [select Business_Unit__c from Agreement_Request__c Where Id=: ApexPages.currentPage().getParameters().get('Id')];
    }
    
    public void someMethod() {
      if(a.Business_Unit__c == 'EIS') {
         a.OwnerID ='00G18000000ZRlS';
         update a;
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You have changed the owner');
          Apexpages.addMessage(errorMessage);
      } else {
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You cannot update');
          Apexpages.addMessage(errorMessage);
      }
    }

}

VF Page:
 
<apex:page controller="classSubmitToLegal"> 
<apex:form>
<apex:commandButton action="{!someMethod}" value="Submit To Legal" id="Submit_to_Legal__c"/>
</apex:form>
</apex:page>

 
I need a custom button  that when pressed, changes the owner of the record and saves the record. I have the class already written, I just need the apex page to go along with it. 

Here is the class that I have: 


public with sharing class classSubmitToLegal {

    public Agreement_Request__c a{get;set;}
    public classSubmitToLegal() {
     a = new Agreement_Request__c ();
     a = [select Business_Unit__c from Agreement_Request__c Where Id=: ApexPages.currentPage().getParameters().get('Id')];
    }
    
    public void someMethod() {
      if(a.Business_Unit__c == 'EIS') {
         a.Business_Unit__c = 'EIS Queue';
         update a;
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You have changed the owner');
          Apexpages.addMessage(errorMessage);
      } else {
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You cannot update');
          Apexpages.addMessage(errorMessage);
      }
    }

}
I have a trigger below and I have some code in the first if else statement that sends out an email but i am running into issues. Can anyone help?

trigger BMIProductUpdate on Product2 (before insert) {
// Purpose: to update fields on products created by BMI based on BMI Product Group Code and Category 
    
    set<string>groupcodeset=new set<string>{};
      set<string>categoryset=new set<string>{};
          map<string, BMI_Product_Custom__c>customsettingmap=new map<string, BMI_Product_Custom__c>();
    
        for(Product2 P: trigger.new)
    {
        
        if(P.BigMachines_Product_Group_Code__c!='' && P.BigMachines_product_Category__c!= ''){
            
            groupcodeset.add(P.BigMachines_Product_Group_Code__c);
            categoryset.add(P.BigMachines_product_Category__c);
        }  
       
    else{
            Messaging.SingleEmailMessage mail = 
             new Messaging.SingleEmailMessage();
    
     List<String> sendTo = new List<String>();
      sendTo.add('frank.jordan@mckesson.com');
      mail.setToAddresses(sendTo);
     
    mail.setReplyTo('frank.jordan@mckesson.com');
      mail.setSenderDisplayName('Frank Jordan');
    
    mail.setSubject('BMI Product with NO Match');
      String body = 'This'  ;
      body += 'Does not have a matching BMI Product Code or Category';
      
      mail.setHtmlBody(body)
          mails.add(mail);
        Messaging.sendEmail(mails);

    
    }
    
    
    
    
    
    
    }
      system.debug('setvalues'+groupcodeset+'category'+categoryset);  
      list<BMI_Product_Custom__c>BMICustomSetting=[Select Asset_Type__c, BigMachines_Product_Category__c, 
                                                   BigMachines_Product_Group_Code__c, Name, Product_Line__c, Id, 
                                                   Revenue_Category__c, SFDC_Executive_Reporting_Group__c, 
                                                   SFDC_Product_Category__c, SFDC_Product_Family__c, 
                                                   SFDC_Product_Sub_category__c, Solution_Group__c, Sub_BU__c, 
                                                   Solution_Set__c, SystemModstamp, Third_party__c 
                                                   FROM BMI_Product_Custom__c where BigMachines_Product_Group_Code__c
                                                   in : groupcodeset and BigMachines_Product_Category__c in :categoryset]; 
system.debug('customlist'+BMICustomSetting);
          for(BMI_Product_Custom__c pc: BMICustomSetting){
              customsettingmap.put(pc.BigMachines_Product_Category__c+pc.BigMachines_Product_Group_Code__c, pc);
         }
  system.debug('customsettingmap'+customsettingmap);  
    for(integer i=0; i<trigger.new.size();i++){
        BMI_Product_Custom__c pc=customsettingmap.get(trigger.new[i].BigMachines_Product_Category__c+trigger.new[i].BigMachines_Product_Group_Code__c );
        if(pc != null){
            trigger.new[i].Product_Line_values__c=pc.Product_Line__c;
            trigger.new[i].Asset_Type__c=pc.Asset_Type__c;
            trigger.new[i].Revenue_Category__c=pc.Revenue_Category__c;
            trigger.new[i].Exec_Rptg_Product_Group__c=pc.SFDC_Executive_Reporting_Group__c;
            trigger.new[i].Product_Category__c=pc.SFDC_Product_Category__c;
            trigger.new[i].Family=pc.SFDC_Product_Family__c;
            trigger.new[i].Product_Sub_Category__c=pc.SFDC_Product_Sub_category__c;
            trigger.new[i].Solution_Group__c=pc.Solution_Group__c;
            trigger.new[i].Solution_Set__c=pc.Solution_Set__c;
            trigger.new[i].Sub_BU__c=pc.Sub_BU__c;
            trigger.new[i].X3rd_Party__c=pc.Third_party__c;
            
            
        }
        //else(send an email to coe if combo was not found)
    }
}
I have a class that is updating the owner of a record when the Submit to Legal button on the "Agreement Request" object is pressed. I am running into the "List has no rows for assignment to SObject" error when pressing the button and i'm not sure why. Below is my code: 

public with sharing class classSubmitToLegal {

    public Agreement_Request__c a{get;set;}
    public classSubmitToLegal() {
     a = new Agreement_Request__c ();
     a = [select Business_Unit__c from Agreement_Request__c Where Id=: ApexPages.currentPage().getParameters().get('Id')];
    }
    
    public void someMethod() {
      if(a.Business_Unit__c == 'EIS') {
         a.Business_Unit__c = 'EIS Queue';
         update a;
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You have changed the owner');
          Apexpages.addMessage(errorMessage);
      } else {
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You cannot update');
          Apexpages.addMessage(errorMessage);
      }
    }

}
I have a formula field that contains a button and when the button is pressed depending on the value of another field, i would like the owner to change to a queue. I'm having trouble writing the class that goes along with this button. can anyone help? I would like it to be similar to the button below (within the field)
User-added image
User-added image

 
I have the following code and I am receiving this error: Invalid field Update_Contract_Request_Summary__c for SObject Opportunity. Does anyone know how to fix this? 
 
public class UpdateRequestContractExttwo_ecsg   {
    private final Opportunity opp;
     
    Opportunity tempOpp ;
   
    public UpdateRequestContractExttwo_ecsg(ApexPages.StandardController stdController) {
        this.opp = (Opportunity)stdController.getRecord();
        tempOpp = [select id ,ContactVerified__c,Contract_Specialist_Assigned__c, type,
                   Master_Agreement_Number__c,Current_Contract_Status__c,Date_Assigned_to_Specialist__c,
                   Date_Contract_Requested__c from Opportunity where id=: stdController.getId()];
        system.debug('--------------opp.id----------------'+opp.id );
    }
 
   
   //this is page load 
   public PageReference pageLoad(){
    
         PageReference oppPage = new ApexPages.StandardController(opp).view();
           oppPage.setRedirect(true);
            
      if(opp.Contract_Request_Date__c == null){ 
           ApexPages.Message errorMsg = new ApexPages.Message(ApexPages.Severity.Error,'A contract has not be requested for this Oppotunity yet');
           ApexPages.addMessage(errorMsg);
           return null ;
      
      }else if(Opp.Update_Contract_Request_Summary__c == null || Opp.Update_Contract_Request_Summary__c =='')
           {
                 ApexPages.Message errorMsg = new ApexPages.Message(ApexPages.Severity.Error,'Please enter Updated Contract Request Summary.');
                 ApexPages.addMessage(errorMsg);
                 return null ;
          }
         else
          {
              // set All associated ARs to Update from Oportunity
              List<Agreement_Request__c> AgreementRequests_to_update=new List<Agreement_Request__c>();
              AgreementRequests_to_update=[Select id,Request_Status__c,Opportunity__c from Agreement_Request__c where Opportunity__c=:opp.Id ];
              if(AgreementRequests_to_update.size()>0)
              {
                  for (Agreement_Request__c ar:AgreementRequests_to_update)
                  {
                      ar.Request_Status__c='Update from Opportunity';
                      ar.Updated_Agreement_Summary__c=opp.Updated_Agreement_Summary__c;
                  }
                 update AgreementRequests_to_update;
              }
                
              
           return oppPage;
         }
   }
   
}

 
I have a class that is updating the owner of a record when the Submit to Legal button on the "Agreement Request" object is pressed. I am running into the "List has no rows for assignment to SObject" error when pressing the button and i'm not sure why. Below is my code: 

public with sharing class classSubmitToLegal {

    public Agreement_Request__c a{get;set;}
    public classSubmitToLegal() {
     a = new Agreement_Request__c ();
     a = [select Business_Unit__c from Agreement_Request__c Where Id=: ApexPages.currentPage().getParameters().get('Id')];
    }
    
    public void someMethod() {
      if(a.Business_Unit__c == 'EIS') {
         a.Business_Unit__c = 'EIS Queue';
         update a;
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You have changed the owner');
          Apexpages.addMessage(errorMessage);
      } else {
          Apexpages.Message errorMessage = new Apexpages.Message(ApexPages.Severity.Info,'You cannot update');
          Apexpages.addMessage(errorMessage);
      }
    }

}