• Matt Cooper 7
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 28
    Replies
I am creating a VF page that basically has different "pages" that each have different questions on them. Each "page" is a different outputpanel that is rendered depending on clicking a Continue or Back button. I have created a few picklists using selectList/selectOption to make other questions appear or not. The problem I'm running into is that I want to make these picklists required before being able to move to the next page, but I can't seem to do so because there is no null option. I would like the picklist to start as null which would make the user choose one of the options before they can continue.
For example, with the following code snippet, I can create a picklist on the page with all the options, but the user can just move to the next page without making a choice.
Class:
public List < SelectOption > getisNDA() { List < SelectOption > options3 = new List < SelectOption > (); List < String > tempList = new List < String > (); tempList.add('Yes'); tempList.add('No'); for (String s: tempList) options3.add(new SelectOption(s, s)); return options3; }


Page:
<apex:selectList id="sel3" value="{!NDA2}" multiselect="false" size="1" tabIndex="70" styleclass="inputc" required="true"> <apex:actionSupport event="onchange" action="{!NDAupdate}" rerender="NDAQ1, NDAQ2" /> <apex:selectOptions value="{!isNDA}" /> </apex:selectList>

 

Hi, 

I am trying to build a trigger that runs directly after a Salesforce approval process is submitted.  Basically, I am trying to copy the approval information into a separate custom object that will create records that have both the approval information (Approver Name, Approval Status, etc.) and my custom object record information.  This will allow me to run more relevant reports off of the approval instances (than available through [out of the box reports](https://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_forcecom_process_approval_history_reports.htm)).  I also need the ability to generate a document with the approval information on it (who approved and when) and I can't find a solution for that without creating records in another object with the approval information copied into it.

I have attempted to run the trigger off of my custom object, but it seems impossible for the trigger to be able to run every time I need it to.  For instance, if there are multiple approvers in a step, there doesn't seem to be a way to update a field on the custom object record until the step is over.  

My question is if there is a way to run triggers off of ProcessInstance records (and subsequently ProcessInstanceStep and ProcessInstanceNode records).  I can't seem to create a trigger using the ProcessInstance object.

Thanks,Matt

Hi, 

I am trying to build a trigger that runs directly after a Salesforce approval process is submitted.  Basically, I am trying to copy the approval information into a separate custom object that will create records that have both the approval information (Approver Name, Approval Status, etc.) and my custom object record information.  This will allow me to run more relevant reports off of the approval instances (than available through [out of the box reports](https://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_forcecom_process_approval_history_reports.htm)).  I also need the ability to generate a document with the approval information on it (who approved and when) and I can't find a solution for that without creating records in another object with the approval information copied into it.

In an attempt to do the above, I have created an after update trigger that is set to run each time an approval process is started and on each step of that process (using field updates).  During the trigger, I am running a query to find the ProcessInstance (and the more specific objects that give the individual approval info). The problem I'm having is that for some reason when I run the query in the trigger, the ProcessInstance Status is set as "Started," but if I run the same query outside of trigger then it is listed as "Pending."  The ProcessInstance record appears to not be set to "Pending" until after the trigger is finished.  This means I can't query to find the actual approvals because the system doesn't think they exist yet.

Has anyone done anything similar like the above or know of a way to do what I'm interested in?

I've put my trigger below.  It's not even close to complete, but I can never get any ProcessInstances found when the approval is first submitted so I want to make sure that is possible first before finishing it up.

Thanks!
 
trigger Approval_History_AR_Trigger on ECM_Appropriations_Request__c (after update) {
        ProcessInstance PI = new ProcessInstance();
        List<ProcessInstance> PIlist = new List<ProcessInstance>();
        List<ProcessInstanceStep> PISlist = new List<ProcessInstanceStep>();
        List<ProcessInstanceWorkItem> WIlist = new List<ProcessInstanceWorkItem>();
        
        for (ECM_Appropriations_Request__c AR :trigger.new)
            {
                system.debug('Approval Status: ' + AR.Approval_Status__c + '     Current Step Update: ' + AR.Step_Update__c + '    Previous Step Update: ' + Trigger.oldMap.get(AR.Id).Step_Update__c + '    If statement (Pending Approval)? ' + (AR.Approval_Status__c == 'Pending Approval') + '    If statement (Step Update)? ' +  (AR.Step_Update__c != Trigger.oldMap.get(AR.Id).Step_Update__c));
                if(AR.Approval_Status__c == 'Pending Approval' && (AR.Step_Update__c != Trigger.oldMap.get(AR.Id).Step_Update__c)){
                    try{
                        for(ProcessInstance p: [SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id  AND Status = 'Pending' LIMIT 1]){
                            PIlist.add(p);
                            system.debug('PIlist.size() = ' + PIlist.size());
                        }
                        PIlist = [SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id  AND Status = 'Started' LIMIT 1];
                        system.debug('There is a Process Instance.');
                        PI=[SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id  AND Status = 'Started' LIMIT 1];
                    }
                    catch(Exception e){
                        system.debug('No ProcesssInstance.  AR.Id=' + AR.id + '    Heres the query:' + [SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id]);
                    }   
                    system.debug('PIlist.size() > 0 = ' + (PIlist.size() > 0));
                    if(PIlist.size() > 0){
                        try{
                            system.debug('PI.Id=  ' + PIlist[0].id + '    Heres the query: ' + [SELECT ActorId,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,OriginalActorId,ProcessInstanceId,SystemModstamp FROM ProcessInstanceWorkitem WHERE ProcessInstanceId = :PIlist[0].id ]);
                            for (ProcessInstanceWorkItem c: [SELECT ActorId,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,OriginalActorId,ProcessInstanceId,SystemModstamp FROM ProcessInstanceWorkitem WHERE ProcessInstanceId = :PIlist[0].id ]) {
                                WIlist.add(c);
                            }
                            system.debug('WIlist size: ' + Wilist.size());
                            if(WIlist.size()>0){
                                   for (Integer i = 0; i < WIlist.size(); i++) {
                                    Approval_History__c AH;
                                    try{                                
                                        AH = [SELECT ID, ProcessInstanceId__c, WorkItemId__c    FROM Approval_History__c WHERE WorkItemId__c = :WIlist[i].Id LIMIT 1];
                                        system.debug('Does AH==null?' + AH.workItemId__c == null);
                                    }
                                    catch (exception e3){
                                        system.debug('No AH record exists.  Does AH==null?' + AH.workItemId__c == null);
                                    }
                                //if([SELECT ID, ProcessInstanceId__c, WorkItemId__c    FROM Approval_History__c WHERE WorkItemId__c = :WIlist[i].Id LIMIT 1]==null){
                                    //Approval_History__c AH = new Approval_History__c(WorkItemId__c = WIlist[i].Id, Approver_Name__c = WIlist[i].ActorId, Date_Assigned__c=WIlist[i].CreatedDate);
                                    if(AH.workItemId__c == null){
                                        AH.WorkItemId__c = WIlist[i].Id;
                                        AH.Approver_Name__c = WIlist[i].ActorId;
                                        AH.Date_Assigned__c=WIlist[i].CreatedDate;
                                        insert AH;
                                    }
                                    else if(AH.Approver_name__c != WIlist[i].ActorId){
                                        AH.Approver_name__c = WIlist[i].ActorId;
                                        update AH;
                                    }
                            }   
                        }                     
                    }
                    catch(exception e2){
                        system.debug('No ProcesssInstanceWorkItems.');
                        system.debug('PI.Id=  ' + PIlist[0].id + '    Heres the query: ' + [SELECT ActorId,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,OriginalActorId,ProcessInstanceId,SystemModstamp FROM ProcessInstanceWorkitem WHERE ProcessInstanceId = :PIlist[0].id ]);
                        
                    }
                    try{
                        for (ProcessInstanceStep c: [select ActorId, Comments, CreatedById, CreatedDate, ElapsedTimeInDays, ElapsedTimeInHours, ElapsedTimeInMinutes, OriginalActorId, Id, ProcessInstanceId, SystemModstamp, StepStatus, StepNodeId from ProcessInstanceStep where ProcessInstanceId=:PIlist[0].id AND StepStatus = 'Approved']) {
                            PISlist.add(c);
                        }
                        if(PISlist.size()>0){
                            for (Integer i = 0; i < WIlist.size(); i++) {
                                Approval_History__c AH = [SELECT ID, ProcessInstanceId__c, WorkItemId__c    FROM Approval_History__c WHERE ProcessInstanceId__c = :PISlist[i].ProcessInstanceId AND Approver_Name__c= :PISlist[i].OriginalActorId LIMIT 1];
                                //if([SELECT ID, ProcessInstanceId__c, WorkItemId__c    FROM Approval_History__c WHERE WorkItemId__c = :WIlist[i].Id LIMIT 1]==null){
                                    //Approval_History__c AH = new Approval_History__c(WorkItemId__c = WIlist[i].Id, Approver_Name__c = WIlist[i].ActorId, Date_Assigned__c=WIlist[i].CreatedDate);
                                if(AH == null){
                                    AH.WorkItemId__c = WIlist[i].Id;
                                    AH.Approver_Name__c = WIlist[i].ActorId;
                                    AH.Date_Assigned__c=WIlist[i].CreatedDate;
                                    insert AH;
                                }
                                else if(AH.Approver_name__c != WIlist[i].ActorId){
                                    AH.Approver_name__c = WIlist[i].ActorId;
                                    update AH;
                                }
                            }   
                        }                     
                    }
                    catch(exception e2){
                        system.debug('No ProcesssInstanceWorkItems');
                    }
                }
                }
                
                
                
            }
    }

 
I am having an issue where I am running a query in a trigger to search for a ProcessInstance record. In my debug, the query returns a record and values. However, when I try to assign that query result to a ProcessInstance variable or add it to a ProcessInstance list, it fails.
try{ for(ProcessInstance p: [SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id AND Status = 'Pending' LIMIT 1]){ PIlist.add(p); system.debug('PIlist.size() = ' + PIlist.size()); } PIlist = [SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id AND Status = 'Pending' LIMIT 1]; PI=[SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id AND Status = 'Pending' LIMIT 1]; } catch(Exception e){ system.debug('No ProcesssInstance. AR.Id=' + AR.id + ' Heres the query:' + [SELECT CompletedDate,CreatedById,CreatedDate,ElapsedTimeInDays,ElapsedTimeInHours,ElapsedTimeInMinutes,Id,IsDeleted,LastActorId,LastModifiedById,LastModifiedDate,ProcessDefinitionId,Status,SubmittedById,SystemModstamp,TargetObjectId FROM ProcessInstance WHERE TargetObjectId = :AR.id]); }


The debug returns: "10:56:21:180 USER_DEBUG [21]|DEBUG|No ProcesssInstance. AR.Id=a1QR0000002zuy8MAA Heres the query:(ProcessInstance:{CreatedById=005o0000000Ip8lAAC, CreatedDate=2016-05-11 17:56:21, ElapsedTimeInDays=0.000, ElapsedTimeInHours=0.00, ElapsedTimeInMinutes=0, Id=04gR0000000JEOnIAO, IsDeleted=false, LastModifiedById=005o0000000Ip8lAAC, LastModifiedDate=2016-05-11 17:56:21, ProcessDefinitionId=04aR00000008TsmIAE, Status=Started, SubmittedById=005o0000000Ip8lAAC, SystemModstamp=2016-05-11 17:56:21, TargetObjectId=a1QR0000002zuy8MAA})"
Any idea why this would be happening?

Hi,

I am trying to build out a new Visualforce page and I'm trying to mess with the styling.  I want to remove the field lines (currently using PageBlock mode="edit"), but I want to keep the tabstyle (colored pageblocksection headers).  Is there a way to accomplish this?

Thanks!

I am trying to pass the value of an inputfield for a lookup field from my Visualforce page to my controller. I can't seem to figure out why, but it continues to return a null value. See below for some snippets of the code. If the below isn't enough and you need more of the code, let me know and I'll post more. The debug returns "Reassignee ID: null"

Controller:
public class Advanced_Approval {
public Apttus_Approval__Approval_Request__c reassignee {get;set;}
User reassignedToUser = new User();
public void userPopulated()
         {
         reassignee = new Apttus_Approval__Approval_Request__c();
         system.debug('Reassignee ID: ' + reassignee.Apttus_Approval__Assigned_To__c);
         reassignedToUser = [select id, Name From User Where id=:reassignee.Apttus_Approval__Assigned_To__c];
         }
}

Visualforce Page:
<apex:outputLabel value="Reassign To " for="assigned" style="font-weight:bold; margin-left 15%" ></apex:outputLabel>
  <apex:actionRegion > 
    <apex:inputField id="assigned" value="{!reassignee.Apttus_Approval__Assigned_To__c}">
      <apex:actionSupport event="onchange" action="{!userPopulated}" rerender="FinancialAidPanel shopDetailSection" />
    </apex:inputField>
</apex:actionRegion>

 
I am trying to build a simple VF page that has 2 buttons on it. One button creates a new record; the other links to the Reports tab. I have been able to get all the functionality working except that I want to have the ability to change the image used for the commandButtons upon hovering over them. However, when I use the below code, the images do not appear (before or after hover) and I'm unsure what the issue is.
 
<apex:page controller="Upload_Executed_Agmt_Button_Class">
    <apex:form enctype="multipart/form-data">
        <style type="text/css">
            .myDataButton{
                background-image: url('/servlet/servlet.FileDownload?file=01517000000Atf5') !important;
            }
            .myDataButton:hover{
                background-image: url('/servlet/servlet.FileDownload?file=01517000000Atol') !important;
            }
        </style>
    <apex:outputPanel id="selected">
        <script type="text/javascript">                  
            function refreshAgmt(){
                window.top.location = "{!redirectUrl}";
            }
        </script>
    </apex:outputPanel>       
    <apex:pageMessages />
    <apex:pageBlock >
        <apex:pageBlockSection showHeader="false" columns="2" id="block1" >
        <apex:pageBlockSectionItem >                  
                <apex:commandButton action="{!createAgmt}" image="/servlet/servlet.FileDownload?file=01517000000Atf0" value="Upload Executed Agreement" styleClass="buttonStyle" style="color:white; font-size: 200%; background:White; margin-left:275px; width:500px; height:auto;"  rerender="selected" oncomplete="refreshAgmt();"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >              
                <apex:commandButton action="{!showReports}" value="Data" styleClass="myDataButton" style=" color:white; font-size: 200%; background:White; margin-left:0px; width:500px; height:auto"  rerender="selected" oncomplete="refreshAgmt();"/>
        </apex:pageBlockSectionItem>   
        </apex:pageBlockSection>
     </apex:pageBlock>
  </apex:form>
</apex:page>

 
I built out a custom button that should run some javascript to update a field value if certain conditions are met. However, when I test the button, the else clause always runs.

Any help on what is wrong with the javascript would be much appreciated:
 
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 

var agmt = new sforce.SObject("Apttus__APTS_Agreement__c");
agmt.Id = '{!Apttus__APTS_Agreement__c.Id}'; 

if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}'== 'Internal Review'){ 
agmt.Apttus__Status__c = 'Other Party Review'; 
result = sforce.connection.update([agmt]); 
window.location.reload(); 
} 

else if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Other Party Review'){ 
alert('This agreement has already been sent for review'); 
} 

else if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Activated' || '{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Fully Signed' ){ 
alert('This agreement is fully signed'); 
} 

else{ 
alert('This agreement must first be sent for legal review'); 
}

 
Hi,

I was wondering if there is a way to create a Visualforce page to be used inline on a master object's page layout that has fields from a detail object.  For example, Object_A will be the master object and Object_B will be the detail object.  I am wondering if it is possible to add an inline VF page to an Object_A page layout that has fields from Object_B.  The usecase would be that there will only be one detail record for each master record.  If possible, it would save our users time in having to create a master record, then a detail record, and then return to the master record.  It would also allow the user to have all of their information in one page.

Anyone ever do anything like this?  Is this even possible?

Thanks!
I have been working on creating a Visualforce page that allows you to choose users and send out emails to those users using apex. The problem I have run into is that the email address that the user can reply to is not working properly. The template I am using is a Visualforce email template which has the replyto email address already input into the template. However, when I reply to the email sent from the apex code, it replies back to the sender, not the email address in the template.

I tried to include the setReplyTo() functionality in my apex, but I get an error when sending a Visualforce email template if I try to choose a replyto email in my apex.

Anyone have any ideas on how to get this working? Let me know if you want me to show my code.

Thanks!
Hi,

I have been working on creating a custom advanced visualforce search page for my users. It's currently working well, but I was wondering if there was a way to bold specific words that get output into a table (containing records). For example, I have a text box where users can start typing in a record name. There is a table that updates dynamically (using javascript) showing all the records found from a query using the text entered into the text box.

Is there a way that I could bold the exact text value in each record name cell so that just the part of the text that was searched for could be in bold? Ex: search for "new" would cause a record name of "Newsworthy" to show up but with just the "New" part in bold. I think this could help users identify the record they are looking for.

Thanks!
Hi, I'm putting together a trigger to handle some of my workflow rules (our org is hitting limits) and I keep getting the following error:
"Error:Apex trigger AR_Email_Alerts caused an unexpected exception, contact your administrator: AR_Email_Alerts: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.AR_Email_Alerts: line 62, column 1"
Usually I get this error when I'm trying to set a variable value to a field that is null.  However, in this case the value I'm using is OwnerId and on a record that already exists.  Can anyone help pinpoint what might be the issue?  Thanks!
 
trigger AR_Email_Alerts on Apttus__APTS_Agreement__c (after insert, after update) {

    String[] toRecipients;
    String[] ccRecipients;
    String templateApiName;
    ID targetObjId;
    Id whatId;
    ID orgWideEmailId;
    Boolean saveAsActivity;
    Attachment[] attachList;
    Map<String, Id> typeMap = New Map<String, Id>();
    recordtype rt2;
    Map<string, id> userEmail = new map<string, id>();
 	ID rtID = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Appropriations Request').getRecordTypeID();
    
    for (Apttus__APTS_Agreement__c agmt :trigger.new){
        if (agmt.recordtypeid == rtID) {
            //Workflow rule for when AR is Activated - updates fields and sends email to AR Preparer and Requestor
            if((agmt.Apttus__Status_Category__c == 'Request' && agmt.Apttus__Workflow_Trigger_Viewed_Final__c == true)
               || (agmt.Apttus_Approval__Approval_Status__c =='Approved' && agmt.AR_Total_Appropriations_Request_Total2__c < 1000) 
               || (agmt.Apttus_Approval__Approval_Status__c =='Approved' && agmt.AR_Capital_Expenditure_Total__c <1000 && agmt.AR_Option_or_New_Lease__c =='Option')){
                   User user1;
                   User user2;
                   user1.id = agmt.Apttus__Requestor__c;
                   user2.id = agmt.AR_Preparer__c;
                   toRecipients.add(user1.email);
                   toRecipients.add(user2.email);
                   templateApiName = 'AR_Activated';
                   targetObjId = user1.id;
                   agmt.Apttus__Activated_Date__c = Date.today();
                   agmt.Apttus__Workflow_Trigger_Viewed_Final__c = false;
                   agmt.Apttus__Status__c = 'Activated';
                   agmt.Apttus__Status_Category__c = 'In Effect';
               }
            //AR Admin Tasks workflow rule - sends email to Owner/AR Admin
            else if(agmt.Apttus__Status__c == 'Approved Request' 
               && agmt.AR_Reference_Number__c == '' 
               && agmt.AR_Total_Appropriations_Request_Total2__c >= 1000 
               && agmt.AR_Option_or_New_Lease__c !='Option'){
                   User user1;
                   user1.id = agmt.Ownerid;
                   toRecipients.add(user1.email);
                   templateApiName = 'AR_Administrator_Admin_Tasks';
                   targetObjId = user1.id;
               }
            //CPMO Admin pause - sends email to Owner/AR Admin to notify the AR Admin to start the CPMO approvals
            else if(agmt.Apttus__Status__c == 'Submitted Request' 
               && agmt.Apttus_Approval__Approval_Status__c =='Not Submitted' 
               && agmt.AR_Total_Appropriations_Request_Total2__c >= 20000){
                   ID oID = agmt.Ownerid;
                   User user1;
                   user1.id = oID;
                   toRecipients.add(user1.email);
                   templateApiName = 'AR_Administrator_CPMO_Admin_Pause';
                   targetObjId = user1.id;
               }
            //Sub-committee Admin pause - sends email to Owner/AR Admin to notify the AR Admin to start the sub-committee approvals
            else if(agmt.Apttus__Status__c == 'Request Approval' 
               && agmt.Apttus_Approval__Approval_Status__c =='Not Submitted' 
               && agmt.AR_Total_Appropriations_Request_Total2__c >= 1000){
                   User user1;
                   user1.id = agmt.Ownerid;
                   toRecipients.add(user1.email);
                   templateApiName = 'AR_Administrator_Subcommittee_Admin_Pause';
                   targetObjId = agmt.Ownerid;
               }
            whatId = '01Io00000009t1OEAQ';
            orgWideEmailId = '0D2o0000000TNsu';
            sendTemplatedEmailClass.sendTemplatedEmail(toRecipients, ccRecipients, templateApiName, targetObjId, whatId, orgWideEmailId);
        }
    }

}

 
Hi, I've been building a VF search page and have run into a slight issue.  I want to add pagination so that I can return all of my results and allow users to go through the results at 20 records a page.  I have been trying to look at instructions online and can't seem to link my results with the pages.  Can anyone take a look and provide me some insight into how I could get pagination with my code?  Thanks!

Controller:
public with sharing class CorpGovSearchController {

   private integer counter=0;  //keeps track of the offset
   private integer list_size=20; //sets the page size or number of rows
   public integer total_size; //used to show user the total size of the list
   public Apttus__APTS_Agreement__c agmt1 {get;set;}
    
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of agreements to display
  public List<Apttus__APTS_Agreement__c> agmts {get;set;}

  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }

  // the current field to sort by. defaults to last name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' LIMIT 100';}
    set;
  }

  // init the controller and display some sample data when the page loads
  public CorpGovSearchController() {
    soql = 'select Name, Nike_SF_Contract_Category__c, Apttus__Agreement_Category__c, NikeSF_Sub_Geography__c, NikeSF_Geography__c, ID, Apttus__Status_Category__c, Apttus__Status__c, NikeSF_Agreement_Type__c from Apttus__APTS_Agreement__c where name != null';
    
    runQuery();
  }

  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }

  // runs the actual query
  public void runQuery() {

    try {
      agmts = Database.query(soql  + ' order by ' + sortField + ' ' + sortDir + ' LIMIT 100');
      total_size= agmts.size();
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }

  }

     public void reset() {
       agmt1.NikeSF_Sub_Geography__c='';
    }
  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {

    String Name = Apexpages.currentPage().getParameters().get('Name');
    String agmtPurpose = Apexpages.currentPage().getParameters().get('agmtPurpose');
    String agmtCategory = Apexpages.currentPage().getParameters().get('agmtCategory');
    String subgeography = Apexpages.currentPage().getParameters().get('subgeography');
    String geography = Apexpages.currentPage().getParameters().get('geography');
    String ID = Apexpages.currentPage().getParameters().get('ID');

    soql = 'select Name, Nike_SF_Contract_Category__c, Apttus__Agreement_Category__c, NikeSF_Sub_Geography__c, NikeSF_Geography__c, ID, Apttus__Status_Category__c, Apttus__Status__c, NikeSF_Agreement_Type__c from Apttus__APTS_Agreement__c where name != null';
    if (!Name.equals(''))
    soql += ' and Name LIKE \'%'+String.escapeSingleQuotes(Name)+'%\'';
    if (!agmtCategory.equals(''))
        soql += ' and Nike_SF_Contract_Category__c LIKE \''+agmtPurpose+'\'';  
    if (!agmtCategory.equals(''))
      soql += ' and Apttus__Agreement_Category__c LIKE \''+agmtCategory+'\'';
    if (!geography.equals(''))
      soql += ' and NikeSF_Geography__c LIKE \'' + ''+geography+'\'';
    if (!subgeography.equals(''))
      soql += ' and NikeSF_Sub_Geography__c LIKE \''+subgeography+'\'';  
    

    // run the query again
    runQuery();

    return null;
  }

   public PageReference Beginning() { //user clicked beginning
      counter = 0;
      return null;
   }
 
   public PageReference Previous() { //user clicked previous button
      counter -= list_size;
      return null;
   }
 
   public PageReference Next() { //user clicked next button
      counter += list_size;
      return null;
   }
 
   public PageReference End() { //user clicked end
      counter = total_size - math.mod(total_size, list_size);
      return null;
   }
 
   public Boolean getDisablePrevious() { 
      //this will disable the previous and beginning buttons
      if (counter>0) return false; else return true;
   }
 
   public Boolean getDisableNext() { //this will disable the next and end buttons
      if (counter + list_size < total_size) return false; else return true;
   }
 
   public Integer getTotal_size() {
      return total_size;
   }
 
   public Integer getPageNumber() {
      return counter/list_size + 1;
   }
 
   public Integer getTotalPages() {
      if (math.mod(total_size, list_size) > 0) {
         return total_size/list_size + 1;
      } else {
         return (total_size/list_size);
      }
   }



}

VF Page:
 
<apex:page controller="CorpGovSearchController" sidebar="false">

  <apex:form >
  <apex:pageMessages id="errors" />

  <apex:pageBlock title="Agreement Search" mode="edit">

  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">

      <apex:pageBlock title="Filters" mode="edit" id="criteria">

      <script type="text/javascript">
      var oldG;
      var oldAP;
      function doSearch() {
        
        if(document.getElementById("{!$Component.geography}").value=='' || document.getElementById("{!$Component.subgeography}").value=='__' || document.getElementById("{!$Component.geography}").value!=oldG){
           document.getElementById("{!$Component.subgeography}").value='';          
           }
          
        if(document.getElementById("{!$Component.agmtPurpose}").value=='' || document.getElementById("{!$Component.agmtCategory}").value=='__' || document.getElementById("{!$Component.agmtPurpose}").value!=oldAP){
           document.getElementById("{!$Component.agmtCategory}").value='';           
           }
          
        oldG = document.getElementById("{!$Component.geography}").value;
        oldAP = document.getElementById("{!$Component.agmtPurpose}").value;
        searchServer(
                document.getElementById("Name").value,
                document.getElementById("{!$Component.agmtPurpose}").value,
                document.getElementById("{!$Component.agmtCategory}").value,
                document.getElementById("{!$Component.geography}").value,
                document.getElementById("{!$Component.subgeography}").value          
                );        
      }

      </script> 
      
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="Name" value="" />
          <apex:param name="agmtPurpose" value="" />
          <apex:param name="agmtCategory" value="" />
          <apex:param name="geography" value="" />
          <apex:param name="subgeography" value="" />          
      </apex:actionFunction>
          

          
      <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">Agreement Name<br/>
        <input type="text" id="Name" onkeyup="doSearch();"/>
        </td>
      </tr>        
       <tr>
           <td style="font-weight:bold;">Agreement Purpose<br/>  
            <apex:inputfield id="agmtPurpose" value="{!agmt1.Nike_SF_Contract_Category__c}"  onchange="doSearch();"/> 
           </td>
      </tr>   
      <tr>
        <td style="font-weight:bold;">Agreement Category<br/>  
        <apex:inputfield id="agmtCategory" value="{!agmt1.Apttus__Agreement_Category__c}"  onchange="doSearch();"/> 
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Geography<br/>
          <apex:inputfield id="geography" value="{!agmt1.NikeSF_Geography__c}"  onchange="doSearch();"/>  
        </td>
      </tr>
          
      <tr>
        <td style="font-weight:bold;">Sub-Geography<br/>
          <apex:inputfield id="subgeography" value="{!agmt1.NikeSF_Sub_Geography__c}"  onchange="doSearch();"/>  
        </td>
      </tr>

      </table>

      </apex:pageBlock>

    </td>
    <td valign="top">

    <apex:pageBlock mode="edit" id="results">
        <apex:pageBlockButtons location="both" >
           <apex:outputPanel id="myButtons">
                <apex:commandButton action="{!Beginning}" title="Beginning" value="<<" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>
                <apex:commandButton action="{!Previous}" title="Previous" value="<Previous" disabled="{!disablePrevious}" reRender="myPanel,myButtons"/>        
                <apex:commandButton action="{!Next}" title="Next" value="Next>" disabled="{!disableNext}" reRender="myPanel,myButtons"/>
                <apex:commandButton action="{!End}" title="End" value=">>" disabled="{!disableNext}" reRender="myPanel,myButtons"/>        
            </apex:outputPanel>
       </apex:pageBlockButtons>
        
       <apex:pageBlockTable value="{!agmts}" var="agmt">

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Agreement Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputLink value="/{!agmt.id}">{!agmt.Name}</apex:outputLink>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Agreement Category" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Apttus__Agreement_Category__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.Apttus__Agreement_Category__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Agreement Type" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="NikeSF_Agreement_Type__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.NikeSF_Agreement_Type__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Status Category" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Apttus__Status_Category__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.Apttus__Status_Category__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Status" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Apttus__Status__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.Apttus__Status__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Geographies" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="NikeSF_Geography__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.NikeSF_Geography__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Sub-Geography" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="NikeSF_Sub_Geography__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.NikeSF_Sub_Geography__c}"/>
            </apex:column>
        
        </apex:pageBlockTable>
    </apex:pageBlock>
    </td>
  </tr>
  </table>

  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />           
  </apex:pageBlock>    

  </apex:pageBlock>

  </apex:form>

</apex:page>


 
Hi, I'm working on building a custom search visualforce page and I've run into a problem.  I have added 2 picklists (one controlling and one dependent) as filtering fields.  However, when I go to the VF page and try to filter, the query returns nothing if Geography is left blank. For some reason, the Sub-Geography field is querying as "__" instead of blank.  I'm guessing that this is caused by the field being faded out when no Geography is selected, but not sure why it is not just outputting as nothing or void.  Also, if I do select a Geography and Sub-Geography then select another Geography the Sub-Geography value stays the same as the older selection.  Does anyone have any ideas on 1) how I can set the Sub-Geography value as blank if no Geography is selected and 2) how to reset the Sub-Geography value to blank when Geography value is changed?

Controller:
 
public with sharing class CorpGovSearchController {

    
  public Apttus__APTS_Agreement__c agmt1 {get;set;}
    
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of agreements to display
  public List<Apttus__APTS_Agreement__c> agmts {get;set;}

  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }

  // the current field to sort by. defaults to last name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }

  // init the controller and display some sample data when the page loads
  public CorpGovSearchController() {
    soql = 'select Name, Apttus__Agreement_Category__c, NikeSF_Sub_Geography__c, NikeSF_Geography__c, ID from Apttus__APTS_Agreement__c where name != null';
    runQuery();
  }

  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }

  // runs the actual query
  public void runQuery() {

    try {
      agmts = Database.query(soql  + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }

  }


  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {

    String Name = Apexpages.currentPage().getParameters().get('Name');
    String agmtCategory = Apexpages.currentPage().getParameters().get('agmtCategory');
    String subgeography = Apexpages.currentPage().getParameters().get('subgeography');
    String geography = Apexpages.currentPage().getParameters().get('geography');
    String ID = Apexpages.currentPage().getParameters().get('ID');

    soql = 'select Name, Apttus__Agreement_Category__c, NikeSF_Sub_Geography__c, NikeSF_Geography__c, ID from Apttus__APTS_Agreement__c where name != null';
    if (!Name.equals(''))
	soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
    if (!agmtCategory.equals(''))
      soql += ' and agmtCategory LIKE \''+String.escapeSingleQuotes(agmtCategory)+'%\'';
    if (!geography.equals(''))
      soql += ' and NikeSF_Geography__c LIKE \'' + ''+geography+'\'';
    if (!subgeography.equals(''))
      soql += ' and NikeSF_Sub_Geography__c LIKE \''+subgeography+'\'';  
    

    // run the query again
    runQuery();

    return null;
  }

  // use apex describe to build the picklist values
  public List<String> geographies {
    get {
      if (geographies == null) {

        geographies = new List<String>();
        Schema.DescribeFieldResult field = Apttus__APTS_Agreement__c.NikeSF_Geography__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          geographies.add(f.getLabel());

      }
      return geographies;          
    }
    set;
  }

      public List<String> subgeographies {
    get {
      if (subgeographies == null) {

        subgeographies = new List<String>();
        Schema.DescribeFieldResult field = Apttus__APTS_Agreement__c.NikeSF_Sub_Geography__c.getDescribe();

        for (Schema.PicklistEntry g : field.getPicklistValues())
          subgeographies.add(g.getLabel());

      }
      return subgeographies;          
    }
    set;
  }
}

Visualforce Page:
 
<apex:page controller="CorpGovSearchController" sidebar="false">

  <apex:form >
  <apex:pageMessages id="errors" />

  <apex:pageBlock title="Agreement Search" mode="edit">

  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">

      <apex:pageBlock title="Filters" mode="edit" id="criteria">

      <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("Name").value,
          document.getElementById("agmtCategory").value,
          document.getElementById("{!$Component.geography}").value,
          document.getElementById("{!$Component.subgeography}").value          
          );
      }

      </script> 
	  
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="Name" value="" />
          <apex:param name="agmtCategory" value="" />
          <apex:param name="geography" value="" />
          <apex:param name="subgeography" value="" />
      </apex:actionFunction>
          

          
      <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">Agreement Name<br/>
        <input type="text" id="Name" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Agreement Category<br/>
        <input type="text" id="agmtCategory" onkeyup="doSearch();"/>
        </td>
      </tr>

      <tr>
        <td style="font-weight:bold;">Geography<br/>
          <apex:inputfield id ="geography" value="{!agmt1.NikeSF_Geography__c}"  onchange="doSearch();"/>  
        </td>
      </tr>
          
      <tr>
        <td style="font-weight:bold;">Sub-Geography<br/>
          <apex:inputfield id ="subgeography" value="{!agmt1.NikeSF_Sub_Geography__c}"  onchange="doSearch();"/>  
        </td>
      </tr>

      </table>

      </apex:pageBlock>

    </td>
    <td valign="top">

    <apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!agmts}" var="agmt">

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Agreement Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputLink value="/{!agmt.id}">{!agmt.Name}</apex:outputLink>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Agreement Category" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Apttus__Agreement_Category__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.Apttus__Agreement_Category__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Geographies" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="NikeSF_Geography__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.NikeSF_Geography__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Sub-Geography" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="NikeSF_Sub_Geography__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.NikeSF_Sub_Geography__c}"/>
            </apex:column>

        </apex:pageBlockTable>

    </apex:pageBlock>

    </td>
  </tr>
  </table>

  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />           
  </apex:pageBlock>    

  </apex:pageBlock>

  </apex:form>

</apex:page>


Thanks!
As an adminstrator of a widely used Salesforce app at a large company, I often have to insert, export, update, and delete records in our software.  I often have to insert/update massive amounts of records from one Salesforce app into another to maintain data quality in my Organization.  After using many other data loader apps and tools, I have found that Enabler for Excel is by far the best data loader.  It allows me to take actions in all of my Orgs directly through Excel while making it easy for me to login (it saves login info and security tokens) and easy to navigate.  Along with taking actions on records, it also allows me to run reports, view field utilization, and convert 15 digit IDs to 18 digit IDs at the click of a button. 

For more information on the Excel app, you can go to the developer's website (http://enabler4excel.herokuapp.com/ (https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B3GBzEAN)) or the AppExchange page (https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B3GBzEAN).
I have been working on building a trigger that would allow my users to use a single Intake Form which would then change the record type based on the values they provide on the Intake Form page layout. Basically, people can come in and make selections based on their circumstances. Those selections will determine which type of record type the record should be. Below is the code that I have been working on that does not seem to be working.
trigger IntakeFormTrigger on Apttus__APTS_Agreement__c (after insert, before update) {
 
    // Get a list of record types.
    Map<ID,RecordType> typeMap = New Map<ID,RecordType>([Select ID, DeveloperName From RecordType Where sObjectType = 'Apttus__APTS_Agreement__c']);
  
    for (Apttus__APTS_Agreement__c agmt : trigger.new)
    {
        // If the Record Type = Intake Form
        if (agmt.RecordType.DeveloperName == 'Intake Form')
        {
            // And the Agreement Category on the record =TEST
                if (agmt.Apttus__Agreement_Category__c == 'TEST')
                {
                    // Then automatically change the Record Type to TEST Agreements.
                    agmt.RecordType = typeMap.get('TEST Agreements');
                }
        }          
    }
}



Any help would be great! Thanks!
Hi,

I have a situation where I have a record type that wants to include an amend type of functionality.  Basically, a record will be created and completed.  Sometimes, a user will have to amend the information to the record, but the user wants to leave the old record alone and just reference back to the old record with a Lookup field.  The functionality I am trying to create is a trigger that would update a field on the parent record to 'Amended' when the child record becomes 'Activated.'

I have attempted to create a trigger to accomplish this, but when I test it, nothing happens.  Can someone help me figure out where I've gone wrong?  

Object: Apttus__APTS_Agreement__c
Field to update on parent record: Apttus__Status_Category__c
Field on child record to look at: Apttus__Status__c

So when Apttus__Status__c = 'Activated' on the child record, I want Apttus__Status_Category__c = 'Amended' on the parent record.
 
trigger AR_Variance_Status_Update on Apttus__APTS_Agreement__c (before insert, before update) {
 
    Map<ID, Apttus__APTS_Agreement__c> parentAgmts = new Map<ID, Apttus__APTS_Agreement__c>();
    List<Id> listIds = new List<Id>();
    
    for (Apttus__APTS_Agreement__c childObj : Trigger.new) {
    	listIds.add(childObj.Variance_For__c);
    }
    
    parentAgmts = new Map<Id, Apttus__APTS_Agreement__c>([SELECT id, Name FROM Apttus__APTS_Agreement__c WHERE ID IN :listIds]);   
    
    for (Apttus__APTS_Agreement__c agmt :trigger.new)
    {
        Apttus__APTS_Agreement__c myParentAgmt = parentAgmts.get(agmt.Variance_For__c);
        
        if(agmt.Apttus__Status__c == 'Activated' && agmt.Variance_For__c <> null)  {
            myParentAgmt.Apttus__Status_Category__c = 'Amended';
        }
    }
}

Thanks!
Matt
Hi,

I have a scenario where I am trying to create an Apex Trigger that updates the Owner on a master record based on the selection made on a picklist in a detail record.

My master object is:
     Label: Agreement
     Object Name: APTS_Agreement
     API Name: Apttus__APTS_Agreement__c

My detail object is:
     Label: Bank Account Details
     Object Name: Bank_Account_Details
     API Name: Bank_Account_Details__c

The picklist field is located on the Bank Account Details object and has a list of users in the system:
     Field Label: TL Approver
     API Name: TL_approver__c

Basically, one user will be coming in and creating an Agreement record.  They will then create a Bank Account Opening detail record off that Agreement record that will have the TL Approver field on it.  Whoever they select from the TL Approver field should then become the Owner of the Agreement record.

Can anyone help me out with this?

Thanks!
Hi,

I have received an error while trying to install Force.com IDE on Eclipse 4.2.3.  Eclipse was installed in C:\eclipse, I'm using Windows 7 64 bit, I ran Eclipse as an Administrator, and I've installed Java 7 JDK.  I followed the instructions located at https://developer.salesforce.com/page/Force.com_IDE_Installation but after I follow Step 7 i get the error below.  Does anyone have a solution for this?

Cannot complete the install because one or more required items could not be found.
  Software being installed: Force.com IDE 31.0.0.201406301722 (com.salesforce.ide.feature.feature.group 31.0.0.201406301722)
  Missing requirement: Force.com IDE 31.0.0.201406301722 (com.salesforce.ide.feature.feature.group 31.0.0.201406301722) requires 'org.apache.xerces 2.9.0'
Hi,

I have created a custom button with the intent that it be used to update a field value.  I have built buttons like this before that have worked successfully, but for some reason this button is not updating any field values.  The alert I setup works, and the page reloads as the code tells it to do.  The only thing that doesn't occur is the field value updating.  Can anyone please help me figure out what is going wrong?

Here are two versions of the code that I built:

VERSION 1:
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}
{
var agmt = new sforce.SObject("Apttus__APTS_Agreement__c");
var agmtId = "{!Apttus__APTS_Agreement__c.Id}";
var status = "Submitted Request";

agmt.Id = agmtId;

if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' != 'Request'){
alert('This agreement has already been sent to Tax.');
}

else{
agmt.Apttus__Status__c  = status;
result = sforce.connection.update([agmt]);
window.location.reload();
}}

VERSION 2:
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}

var agmt = new sforce.SObject("Apttus__APTS_Agreement__c");
agmt.Id = '{!Apttus__APTS_Agreement__c.Id}';

if(agmt.Apttus__Status__c != 'Request'){
alert('This agreement has already been sent to Tax.');
}

else{
agmt.Apttus__Status__c  = 'Submitted Request';
result = sforce.connection.update([agmt]);
window.location.reload();
}

Thanks!
As an adminstrator of a widely used Salesforce app at a large company, I often have to insert, export, update, and delete records in our software.  I often have to insert/update massive amounts of records from one Salesforce app into another to maintain data quality in my Organization.  After using many other data loader apps and tools, I have found that Enabler for Excel is by far the best data loader.  It allows me to take actions in all of my Orgs directly through Excel while making it easy for me to login (it saves login info and security tokens) and easy to navigate.  Along with taking actions on records, it also allows me to run reports, view field utilization, and convert 15 digit IDs to 18 digit IDs at the click of a button. 

For more information on the Excel app, you can go to the developer's website (http://enabler4excel.herokuapp.com/ (https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B3GBzEAN)) or the AppExchange page (https://appexchange.salesforce.com/listingDetail?listingId=a0N3000000B3GBzEAN).

Hi, 

I am trying to build a trigger that runs directly after a Salesforce approval process is submitted.  Basically, I am trying to copy the approval information into a separate custom object that will create records that have both the approval information (Approver Name, Approval Status, etc.) and my custom object record information.  This will allow me to run more relevant reports off of the approval instances (than available through [out of the box reports](https://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_forcecom_process_approval_history_reports.htm)).  I also need the ability to generate a document with the approval information on it (who approved and when) and I can't find a solution for that without creating records in another object with the approval information copied into it.

I have attempted to run the trigger off of my custom object, but it seems impossible for the trigger to be able to run every time I need it to.  For instance, if there are multiple approvers in a step, there doesn't seem to be a way to update a field on the custom object record until the step is over.  

My question is if there is a way to run triggers off of ProcessInstance records (and subsequently ProcessInstanceStep and ProcessInstanceNode records).  I can't seem to create a trigger using the ProcessInstance object.

Thanks,Matt

Hi,

I am trying to build out a new Visualforce page and I'm trying to mess with the styling.  I want to remove the field lines (currently using PageBlock mode="edit"), but I want to keep the tabstyle (colored pageblocksection headers).  Is there a way to accomplish this?

Thanks!

I am trying to pass the value of an inputfield for a lookup field from my Visualforce page to my controller. I can't seem to figure out why, but it continues to return a null value. See below for some snippets of the code. If the below isn't enough and you need more of the code, let me know and I'll post more. The debug returns "Reassignee ID: null"

Controller:
public class Advanced_Approval {
public Apttus_Approval__Approval_Request__c reassignee {get;set;}
User reassignedToUser = new User();
public void userPopulated()
         {
         reassignee = new Apttus_Approval__Approval_Request__c();
         system.debug('Reassignee ID: ' + reassignee.Apttus_Approval__Assigned_To__c);
         reassignedToUser = [select id, Name From User Where id=:reassignee.Apttus_Approval__Assigned_To__c];
         }
}

Visualforce Page:
<apex:outputLabel value="Reassign To " for="assigned" style="font-weight:bold; margin-left 15%" ></apex:outputLabel>
  <apex:actionRegion > 
    <apex:inputField id="assigned" value="{!reassignee.Apttus_Approval__Assigned_To__c}">
      <apex:actionSupport event="onchange" action="{!userPopulated}" rerender="FinancialAidPanel shopDetailSection" />
    </apex:inputField>
</apex:actionRegion>

 
I built out a custom button that should run some javascript to update a field value if certain conditions are met. However, when I test the button, the else clause always runs.

Any help on what is wrong with the javascript would be much appreciated:
 
{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")} 

var agmt = new sforce.SObject("Apttus__APTS_Agreement__c");
agmt.Id = '{!Apttus__APTS_Agreement__c.Id}'; 

if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}'== 'Internal Review'){ 
agmt.Apttus__Status__c = 'Other Party Review'; 
result = sforce.connection.update([agmt]); 
window.location.reload(); 
} 

else if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Other Party Review'){ 
alert('This agreement has already been sent for review'); 
} 

else if('{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Activated' || '{!Apttus__APTS_Agreement__c.Apttus__Status__c}' == 'Fully Signed' ){ 
alert('This agreement is fully signed'); 
} 

else{ 
alert('This agreement must first be sent for legal review'); 
}

 
Hi, I'm putting together a trigger to handle some of my workflow rules (our org is hitting limits) and I keep getting the following error:
"Error:Apex trigger AR_Email_Alerts caused an unexpected exception, contact your administrator: AR_Email_Alerts: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.AR_Email_Alerts: line 62, column 1"
Usually I get this error when I'm trying to set a variable value to a field that is null.  However, in this case the value I'm using is OwnerId and on a record that already exists.  Can anyone help pinpoint what might be the issue?  Thanks!
 
trigger AR_Email_Alerts on Apttus__APTS_Agreement__c (after insert, after update) {

    String[] toRecipients;
    String[] ccRecipients;
    String templateApiName;
    ID targetObjId;
    Id whatId;
    ID orgWideEmailId;
    Boolean saveAsActivity;
    Attachment[] attachList;
    Map<String, Id> typeMap = New Map<String, Id>();
    recordtype rt2;
    Map<string, id> userEmail = new map<string, id>();
 	ID rtID = Schema.SObjectType.Apttus__APTS_Agreement__c.getRecordTypeInfosByName().get('Appropriations Request').getRecordTypeID();
    
    for (Apttus__APTS_Agreement__c agmt :trigger.new){
        if (agmt.recordtypeid == rtID) {
            //Workflow rule for when AR is Activated - updates fields and sends email to AR Preparer and Requestor
            if((agmt.Apttus__Status_Category__c == 'Request' && agmt.Apttus__Workflow_Trigger_Viewed_Final__c == true)
               || (agmt.Apttus_Approval__Approval_Status__c =='Approved' && agmt.AR_Total_Appropriations_Request_Total2__c < 1000) 
               || (agmt.Apttus_Approval__Approval_Status__c =='Approved' && agmt.AR_Capital_Expenditure_Total__c <1000 && agmt.AR_Option_or_New_Lease__c =='Option')){
                   User user1;
                   User user2;
                   user1.id = agmt.Apttus__Requestor__c;
                   user2.id = agmt.AR_Preparer__c;
                   toRecipients.add(user1.email);
                   toRecipients.add(user2.email);
                   templateApiName = 'AR_Activated';
                   targetObjId = user1.id;
                   agmt.Apttus__Activated_Date__c = Date.today();
                   agmt.Apttus__Workflow_Trigger_Viewed_Final__c = false;
                   agmt.Apttus__Status__c = 'Activated';
                   agmt.Apttus__Status_Category__c = 'In Effect';
               }
            //AR Admin Tasks workflow rule - sends email to Owner/AR Admin
            else if(agmt.Apttus__Status__c == 'Approved Request' 
               && agmt.AR_Reference_Number__c == '' 
               && agmt.AR_Total_Appropriations_Request_Total2__c >= 1000 
               && agmt.AR_Option_or_New_Lease__c !='Option'){
                   User user1;
                   user1.id = agmt.Ownerid;
                   toRecipients.add(user1.email);
                   templateApiName = 'AR_Administrator_Admin_Tasks';
                   targetObjId = user1.id;
               }
            //CPMO Admin pause - sends email to Owner/AR Admin to notify the AR Admin to start the CPMO approvals
            else if(agmt.Apttus__Status__c == 'Submitted Request' 
               && agmt.Apttus_Approval__Approval_Status__c =='Not Submitted' 
               && agmt.AR_Total_Appropriations_Request_Total2__c >= 20000){
                   ID oID = agmt.Ownerid;
                   User user1;
                   user1.id = oID;
                   toRecipients.add(user1.email);
                   templateApiName = 'AR_Administrator_CPMO_Admin_Pause';
                   targetObjId = user1.id;
               }
            //Sub-committee Admin pause - sends email to Owner/AR Admin to notify the AR Admin to start the sub-committee approvals
            else if(agmt.Apttus__Status__c == 'Request Approval' 
               && agmt.Apttus_Approval__Approval_Status__c =='Not Submitted' 
               && agmt.AR_Total_Appropriations_Request_Total2__c >= 1000){
                   User user1;
                   user1.id = agmt.Ownerid;
                   toRecipients.add(user1.email);
                   templateApiName = 'AR_Administrator_Subcommittee_Admin_Pause';
                   targetObjId = agmt.Ownerid;
               }
            whatId = '01Io00000009t1OEAQ';
            orgWideEmailId = '0D2o0000000TNsu';
            sendTemplatedEmailClass.sendTemplatedEmail(toRecipients, ccRecipients, templateApiName, targetObjId, whatId, orgWideEmailId);
        }
    }

}

 
Hi, I'm working on building a custom search visualforce page and I've run into a problem.  I have added 2 picklists (one controlling and one dependent) as filtering fields.  However, when I go to the VF page and try to filter, the query returns nothing if Geography is left blank. For some reason, the Sub-Geography field is querying as "__" instead of blank.  I'm guessing that this is caused by the field being faded out when no Geography is selected, but not sure why it is not just outputting as nothing or void.  Also, if I do select a Geography and Sub-Geography then select another Geography the Sub-Geography value stays the same as the older selection.  Does anyone have any ideas on 1) how I can set the Sub-Geography value as blank if no Geography is selected and 2) how to reset the Sub-Geography value to blank when Geography value is changed?

Controller:
 
public with sharing class CorpGovSearchController {

    
  public Apttus__APTS_Agreement__c agmt1 {get;set;}
    
  // the soql without the order and limit
  private String soql {get;set;}
  // the collection of agreements to display
  public List<Apttus__APTS_Agreement__c> agmts {get;set;}

  // the current sort direction. defaults to asc
  public String sortDir {
    get  { if (sortDir == null) {  sortDir = 'asc'; } return sortDir;  }
    set;
  }

  // the current field to sort by. defaults to last name
  public String sortField {
    get  { if (sortField == null) {sortField = 'Name'; } return sortField;  }
    set;
  }

  // format the soql for display on the visualforce page
  public String debugSoql {
    get { return soql + ' order by ' + sortField + ' ' + sortDir + ' limit 20'; }
    set;
  }

  // init the controller and display some sample data when the page loads
  public CorpGovSearchController() {
    soql = 'select Name, Apttus__Agreement_Category__c, NikeSF_Sub_Geography__c, NikeSF_Geography__c, ID from Apttus__APTS_Agreement__c where name != null';
    runQuery();
  }

  // toggles the sorting of query from asc<-->desc
  public void toggleSort() {
    // simply toggle the direction
    sortDir = sortDir.equals('asc') ? 'desc' : 'asc';
    // run the query again
    runQuery();
  }

  // runs the actual query
  public void runQuery() {

    try {
      agmts = Database.query(soql  + ' order by ' + sortField + ' ' + sortDir + ' limit 20');
    } catch (Exception e) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Ooops!'));
    }

  }


  // runs the search with parameters passed via Javascript
  public PageReference runSearch() {

    String Name = Apexpages.currentPage().getParameters().get('Name');
    String agmtCategory = Apexpages.currentPage().getParameters().get('agmtCategory');
    String subgeography = Apexpages.currentPage().getParameters().get('subgeography');
    String geography = Apexpages.currentPage().getParameters().get('geography');
    String ID = Apexpages.currentPage().getParameters().get('ID');

    soql = 'select Name, Apttus__Agreement_Category__c, NikeSF_Sub_Geography__c, NikeSF_Geography__c, ID from Apttus__APTS_Agreement__c where name != null';
    if (!Name.equals(''))
	soql += ' and Name LIKE \''+String.escapeSingleQuotes(Name)+'%\'';
    if (!agmtCategory.equals(''))
      soql += ' and agmtCategory LIKE \''+String.escapeSingleQuotes(agmtCategory)+'%\'';
    if (!geography.equals(''))
      soql += ' and NikeSF_Geography__c LIKE \'' + ''+geography+'\'';
    if (!subgeography.equals(''))
      soql += ' and NikeSF_Sub_Geography__c LIKE \''+subgeography+'\'';  
    

    // run the query again
    runQuery();

    return null;
  }

  // use apex describe to build the picklist values
  public List<String> geographies {
    get {
      if (geographies == null) {

        geographies = new List<String>();
        Schema.DescribeFieldResult field = Apttus__APTS_Agreement__c.NikeSF_Geography__c.getDescribe();

        for (Schema.PicklistEntry f : field.getPicklistValues())
          geographies.add(f.getLabel());

      }
      return geographies;          
    }
    set;
  }

      public List<String> subgeographies {
    get {
      if (subgeographies == null) {

        subgeographies = new List<String>();
        Schema.DescribeFieldResult field = Apttus__APTS_Agreement__c.NikeSF_Sub_Geography__c.getDescribe();

        for (Schema.PicklistEntry g : field.getPicklistValues())
          subgeographies.add(g.getLabel());

      }
      return subgeographies;          
    }
    set;
  }
}

Visualforce Page:
 
<apex:page controller="CorpGovSearchController" sidebar="false">

  <apex:form >
  <apex:pageMessages id="errors" />

  <apex:pageBlock title="Agreement Search" mode="edit">

  <table width="100%" border="0">
  <tr>  
    <td width="200" valign="top">

      <apex:pageBlock title="Filters" mode="edit" id="criteria">

      <script type="text/javascript">
      function doSearch() {
        searchServer(
          document.getElementById("Name").value,
          document.getElementById("agmtCategory").value,
          document.getElementById("{!$Component.geography}").value,
          document.getElementById("{!$Component.subgeography}").value          
          );
      }

      </script> 
	  
      <apex:actionFunction name="searchServer" action="{!runSearch}" rerender="results,debug,errors">
          <apex:param name="Name" value="" />
          <apex:param name="agmtCategory" value="" />
          <apex:param name="geography" value="" />
          <apex:param name="subgeography" value="" />
      </apex:actionFunction>
          

          
      <table cellpadding="2" cellspacing="2">
      <tr>
        <td style="font-weight:bold;">Agreement Name<br/>
        <input type="text" id="Name" onkeyup="doSearch();"/>
        </td>
      </tr>
      <tr>
        <td style="font-weight:bold;">Agreement Category<br/>
        <input type="text" id="agmtCategory" onkeyup="doSearch();"/>
        </td>
      </tr>

      <tr>
        <td style="font-weight:bold;">Geography<br/>
          <apex:inputfield id ="geography" value="{!agmt1.NikeSF_Geography__c}"  onchange="doSearch();"/>  
        </td>
      </tr>
          
      <tr>
        <td style="font-weight:bold;">Sub-Geography<br/>
          <apex:inputfield id ="subgeography" value="{!agmt1.NikeSF_Sub_Geography__c}"  onchange="doSearch();"/>  
        </td>
      </tr>

      </table>

      </apex:pageBlock>

    </td>
    <td valign="top">

    <apex:pageBlock mode="edit" id="results">

        <apex:pageBlockTable value="{!agmts}" var="agmt">

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Agreement Name" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputLink value="/{!agmt.id}">{!agmt.Name}</apex:outputLink>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Agreement Category" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="Apttus__Agreement_Category__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.Apttus__Agreement_Category__c}"/>
            </apex:column>

            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Geographies" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="NikeSF_Geography__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.NikeSF_Geography__c}"/>
            </apex:column>
            
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="Sub-Geography" action="{!toggleSort}" rerender="results,debug">
                        <apex:param name="sortField" value="NikeSF_Sub_Geography__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputField value="{!agmt.NikeSF_Sub_Geography__c}"/>
            </apex:column>

        </apex:pageBlockTable>

    </apex:pageBlock>

    </td>
  </tr>
  </table>

  <apex:pageBlock title="Debug - SOQL" id="debug">
      <apex:outputText value="{!debugSoql}" />           
  </apex:pageBlock>    

  </apex:pageBlock>

  </apex:form>

</apex:page>


Thanks!
I am having problems adding an image as a background to a VF page.  I only know the basics of HTML and I have been searching for a way to do so with no luck.  I tried following the steps on this page but nothing seemed to happen when I followed the steps and added this code.

https://success.salesforce.com/answers?id=90630000000grroAAA
<apex:stylesheet value="{!URLFOR($Resource.imageStyle, 'customCss.css')}"/>

I want to use the blue background image from this website, and I believe its a simple image that repeats if it helps.  Thanks.
http://www.acmeunited.com/

Thanks.
Hi,

I have a situation where I have a record type that wants to include an amend type of functionality.  Basically, a record will be created and completed.  Sometimes, a user will have to amend the information to the record, but the user wants to leave the old record alone and just reference back to the old record with a Lookup field.  The functionality I am trying to create is a trigger that would update a field on the parent record to 'Amended' when the child record becomes 'Activated.'

I have attempted to create a trigger to accomplish this, but when I test it, nothing happens.  Can someone help me figure out where I've gone wrong?  

Object: Apttus__APTS_Agreement__c
Field to update on parent record: Apttus__Status_Category__c
Field on child record to look at: Apttus__Status__c

So when Apttus__Status__c = 'Activated' on the child record, I want Apttus__Status_Category__c = 'Amended' on the parent record.
 
trigger AR_Variance_Status_Update on Apttus__APTS_Agreement__c (before insert, before update) {
 
    Map<ID, Apttus__APTS_Agreement__c> parentAgmts = new Map<ID, Apttus__APTS_Agreement__c>();
    List<Id> listIds = new List<Id>();
    
    for (Apttus__APTS_Agreement__c childObj : Trigger.new) {
    	listIds.add(childObj.Variance_For__c);
    }
    
    parentAgmts = new Map<Id, Apttus__APTS_Agreement__c>([SELECT id, Name FROM Apttus__APTS_Agreement__c WHERE ID IN :listIds]);   
    
    for (Apttus__APTS_Agreement__c agmt :trigger.new)
    {
        Apttus__APTS_Agreement__c myParentAgmt = parentAgmts.get(agmt.Variance_For__c);
        
        if(agmt.Apttus__Status__c == 'Activated' && agmt.Variance_For__c <> null)  {
            myParentAgmt.Apttus__Status_Category__c = 'Amended';
        }
    }
}

Thanks!
Matt
Hi,

I have a scenario where I am trying to create an Apex Trigger that updates the Owner on a master record based on the selection made on a picklist in a detail record.

My master object is:
     Label: Agreement
     Object Name: APTS_Agreement
     API Name: Apttus__APTS_Agreement__c

My detail object is:
     Label: Bank Account Details
     Object Name: Bank_Account_Details
     API Name: Bank_Account_Details__c

The picklist field is located on the Bank Account Details object and has a list of users in the system:
     Field Label: TL Approver
     API Name: TL_approver__c

Basically, one user will be coming in and creating an Agreement record.  They will then create a Bank Account Opening detail record off that Agreement record that will have the TL Approver field on it.  Whoever they select from the TL Approver field should then become the Owner of the Agreement record.

Can anyone help me out with this?

Thanks!

would any one explain me  the effect of    " mode = 'edit ' " attribute in <apex:pageBlock  mode="edit"></apex:pageBlock>

Step 1. I setup a lookup filter on asset object.

Asset Object -> Contact field -> Lookup filter: Asset: Account ID equals Contact: Account Name ID

 

Step 2. Create few contacts linked to one account.

 

Step 3. Add a new asset via contact page, click on the lookup contact to select different contact.

 

The pop-up window shows:

 

"An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 198796485-896 (960359317)"

 

Help anyone?


Thanks in advance.

  • July 21, 2010
  • Like
  • 0

I have an apex command button as below calling a custom controller method

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="this.disabled=true;"/>

 

The method saves the item and navigate to another page. It is not a partial page update call.

 

I would like to disable button after the first click. I tried using onclick and calling a javascript to set the disabled status as true. When I use onclick even to make the javascript call, the button becomes disabled, but the save method on the controller is not being called.

 

I changed the button onclick event  to just alert 'hi' as below and it works. It alerts and then also makes the method call

 

<apex:commandButton value="Save" id="Save" action="{!save}" onclick="alert('hi');"/> 

 

But when I added the code to disable the button too as shown below, it stops calling the controller method.

 

<apex:commandButton value="Add Item(s)" id="addItem" action="{!addItems}" onclick="alert('hi');this.disabled=true;"/>

 

Is there a different way to solve this?

Message Edited by DCS on 05-07-2009 02:03 PM
  • May 07, 2009
  • Like
  • 0