• Forrest Muldune
  • NEWBIE
  • 50 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 67
    Replies
All,

I am wondering if there is a way to create a button, that will start another Button ( with conga composer parameters) based on a checkbox field in my custom object.

Currently, I have the following below created in my Recommendation__c custom object

1. Checkbox field - Docusign_Button_Start__c
2. Button with Conga parameters - Send_To_Docusign
3. Docusign_Button_Start javascript button 




Request - When a user selects the Docusign_Button_Start , if the Docusign_Button_Start__c checbox field = FALSE, then I would like a Validation Rule to prevent the Send_To_Docusign button from starting. 

In the Docusign_Button_Start javascript button, I have the following code below, but I am having a difficult time trying to find the code that will trigger the Send_To_Docusign button.

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

if({!Recommendation__c.Docusign_Button_Start__c  = FALSE}) {
alert ("Need to select the Docusign Button Start Checkbox ");
}
else{
window.open();
}

I could appreciate all your help. 
 
All,
 
I woul appreciate any help with my requirement below .  I am kind of new in coding and I would appreciate any assitance

REQUIREMENT
 
When Opportunity record is connected to one or more Matter__c  record, Sum all currency values in the Total_Fees__c currency field and add Sum total value in the Engagement_Total_Fees__c field in the related Opportunity record
 
OBJECTS
Opportunity (parent object)
Matter__c  (Child object) custom object.
 
 
OPPORTUNITY FIELD
Engagement_Total_Fees__c - currency (16,2) custom field
 
MATTER__C field
Total_Fees__c - currency (16,2) custom field
Deal__c  - Lookup(Opportunity) custom field
 

WHAT I HAD DONE
 
Below is a trigger I created based on website https://github.com/abhinavguptas/Salesforce-Lookup-Rollup-Summaries .
 
I am requesting if you can review my code because I received the error below
 
“Error: Compile Error: Invalid type: LREngine.Context at line 26 column 33”
 The data on line 26 is “LREngine.Context ctx = new LREngine.Context(Opportunity.SobjectType, // parent object

Trigger Below

/* Updated version on 17 June 16

*/

trigger OppRollupOnEngagement on Matter__c (after insert, after update, 
                                        after delete, after undelete) 

// modified objects whose parent records should be updated
     {Matter__c[] objects = null;

if (Trigger.isDelete) {
         objects = Trigger.old;

 /*
      Handle any filtering required, specially on Trigger.isUpdate event. If the rolled up fields
      are not changed, then please make sure you skip the rollup operation.
      We are not adding that for sake of similicity of this illustration.
 */ 
        objects = Trigger.new;
     }

/*
      First step is to create a context for LREngine, by specifying parent and child objects and
      lookup relationship field name
*/
     LREngine.Context ctx = new LREngine.Context(Opportunity.SobjectType, // parent object
                                            Matter__c.SobjectType,  // child object
                                            Schema.SObjectType.Matter__c.fields.Deal__c // relationship field name
                                            ); 

/*
      Next, one can add multiple rollup fields on the above relationship. 
      Here specify 
       1. The field to aggregate in child object
       2. The field to which aggregated value will be saved in master/parent object
       3. The aggregate operation to be done i.e. SUM, AVG, COUNT, MIN/MAX
*/

ctx.add(
            new LREngine.RollupSummaryField(
                                            Schema.SObjectType.Opportunity.fields.Engagement_Total_Fees__c,
                                            Schema.SObjectType.Matter__c.fields.Total_Fees__c,
                                            LREngine.RollupOperation.Sum 
                                         )); 
/* 
      Calling rollup method returns in memory master objects with aggregated values in them. 
      Please note these master records are not persisted back, so that client gets a chance 
      to post process them after rollup
*/ 

Sobject[] masters = LREngine.rollUp(ctx, objects);    

     // Persiste the changes in master
     update masters;

}



I would appreciate the help . 
 
All,

I have a custom object Matter__c  label is Engagement with a lookup relationship field Deal__c  datatype Lookup(Opportunity) that connects to Opportunity. Opportunities object in my Salesforce database is rename to Deal__c  .
 
I am requesting if the currency value in the custom currency (16,2)  field Total_Fees__c in the custom object  Matter__c which may contain one or more records ,  will Rollup Summary into the related Opportunity ( Deal__c ) record,   within the custom currency (16,2) field Engagement_Total_Fees__c .  For each Deal__c record there can be one or  many Matter__c  records.
 
I created a Trigger below but it is not working. I believe the trigger does not have coding that will place the currency values in the Total_Fees__c field in Matter__c records to be summarize in the Engagement_Total_Fees__c in the Deal__c record.
 
I am not an expert in triggers and I could appreciate the help.

trigger UpdateEngagementTotalFees on Matter__c (After insert,After update,After delete){
    Set<String>dealIds= new Set<String>();
    if(Trigger.isDelete){
        for(Matter__c mat : Trigger.old){
            dealIds.add(mat.Deal__c);
        }
    }else if(Trigger.isUpdate){
       for(Matter__c mat : Trigger.New){
            if(mat.Deal__c != trigger.oldMap.get(mat.id).Deal__c || mat.Total_Fees__c !=trigger.oldMap.get(mat.id).Total_Fees__c){
                if(mat.Deal__c!=null)
                    dealIds.add(mat.Deal__c);
                if(trigger.oldMap.get(mat.id).Deal__c!=null)
                  dealIds.add(trigger.oldMap.get(mat.id).Deal__c);  
            }
       } 
    }else{
        for(Matter__c mat : Trigger.New){
            if(mat.Deal__c != null){
                dealIds.add(mat.Deal__c);
            }
        }
    }
    if(dealIds.size()>0){
        TriggerUtility.rollupBookValues(dealIds,'Matter__c');
    }
    }
 
All,

I created an Apex Trigger below, but I assume it is firing after a user selects the "Submit" button. I would like for this trigger to fire after someone selects either the " Approve " button or " Reject " button.

I would appreciate your help 




trigger TriggerApprover on Matter__c (before update) {
   
       if(trigger.isUpdate){
             List<Matter__c> MatterList =  [Select id,
                                                   (Select Id,
                                                         IsPending,
                                                         ProcessInstanceId,
                                                         TargetObjectId,
                                                         StepStatus,
                                                         OriginalActorId,
                                                         ActorId,
                                                         RemindersSent,
                                                         Comments,
                                                         IsDeleted,
                                                         CreatedDate,
                                                         CreatedById,
                                                         SystemModstamp
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC)
                                                    From Matter__c
                                                WHERE Id IN : Trigger.new];
 
             if(MatterList.size() > 0){
 
               for(Matter__c mat : MatterList){
             
                for(Matter__c mat1 : Trigger.new) {
                 
                         //check copy comment is true
                         if(mat.id == mat1.id && mat1.Copy_Comment__c) {
 
                           if (mat.ProcessSteps.size() > 0) {
                           
                         mat1.Approver_Comment__c = mat.ProcessSteps[0].Comments;
                         mat1.copy_comment__c = false;
               
                           }
 
                        }
                
                    }
               }
             }  
        } 
    }
 
All,

I created a trigger ( view below)  that will take values from  the Comments field when an Approver either Approves or Rejects a record, the values in the comment field  will then be inserted in the  Approver_Comment__c long text field located in the  matter__c custom object. However, When I created an email alert for the Final Approval Actions and Final Rejection Actions in the Approval Process, the email does not send me the current information in the Approver_Comment__c in the matter__c custom object, it only sends me the older value. Example if value "Test 1" already exist in the Approver_Comment__c and the approver approves the same record and writes "Test 2" in the Comments fieldd before approving or rejecting the record, after the approver selects the Approve or Reject button, the value "Test 1"  will be send in the email alert , not the value "Test 2". I appreciate the help. I want the most current value in the comments field which in this siutation  is "Test 2" to be sent via the email alert. 

I could appreciate it if someone could assist me on this. 
 
 
trigger TriggerApprover on Matter__c (before update) {
   
       if(trigger.isUpdate){
             List<Matter__c> MatterList =  [Select id,
                                                   (Select Id,
                                                         IsPending,
                                                         ProcessInstanceId,
                                                         TargetObjectId,
                                                         StepStatus,
                                                         OriginalActorId,
                                                         ActorId,
                                                         RemindersSent,
                                                         Comments,
                                                         IsDeleted,
                                                         CreatedDate,
                                                         CreatedById,
                                                         SystemModstamp
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC)
                                                    From Matter__c
                                                WHERE Id IN : Trigger.new];
 
             if(MatterList.size() > 0){
 
               for(Matter__c mat : MatterList){
             
                for(Matter__c mat1 : Trigger.new) {
                 
                         //check copy comment is true
                         if(mat.id == mat1.id && mat1.Copy_Comment__c) {
 
                           if (mat.ProcessSteps.size() > 0) {
                           
                         mat1.Approver_Comment__c = mat.ProcessSteps[0].Comments;
                         mat1.copy_comment__c = false;
               
                           }
 
                        }
                
                    }
               }
             }  
        } 
    }
 
All,

Within my Inbound Change Sets in my production Instance, I did a Validation to my change set and I received the results below

User-added image

User-added image

Does anyone have any recommendations how I can fix these issues?  

Can I successfuly Deploy this change set ?

This is my first time migrating information from my sandbox to production and any help will be greatly appreciated.

Regards,
All,

I have set an Approval Process on a custom object Matter__c . 

I would like when a Approver writes a comment when he approves or rejects an Approval, I would like the comment to be placed in the approval_comments__c ( long text ) in Matter__c object. Is there a way to do this through Process Builder or Workflow Rules? Or do I have to create a Trigger?

If I need to create a trigger does anyone have an example of a trigger code?

I appreciate anyone help. 
All,

I have a one to many relationship between Opportunities and a custom object name Loan__c (one Opportunity to many Loan__c). When I delete a loan record, my trigger below does not fire. 

Does anyone know how to update this code so that when I delete a loan record, the trigger will fire?

Trigger updateDealWithLoanInfo2 on Loan__c (after insert, after update) {
    if(Trigger.isAfter && ( Trigger.isInsert || Trigger.isUpdate )) {
        map<id,id> dealMap = new map<id,id>();
        set<id> consumerDeals = new set<id>();
        set<id> consumerDealsYellow = new set<id>();
        set<id> participatedDeals = new set<id>();
        list<Loan__c> loans = new List<Loan__c>();  
        list<Opportunity> deals = new List<Opportunity>();  
        list<Opportunity> updatedDeals = new List<Opportunity>();  

        for(Loan__c l : Trigger.new) {
            if(l.Deal__c <> NULL) {
                dealMap.put(l.Deal__c, l.Id);
            }
        }
        if(dealMap.size()>0){
            loans = [Select Deal__c, Consumer__c, Participated__c from Loan__c where Deal__c in :dealMap.keySet()];
            for (Loan__c l2 : loans){
                if(l2.Consumer__c == 'Consumer'){
                    consumerDeals.add(l2.Deal__c);
                }
                if(l2.Consumer__c == 'Ambiguous' || l2.Consumer__c == NULL || l2.Consumer__c == 'Insufficient information'|| l2.Consumer__c == 'Not reviewed'){
                    consumerDealsYellow.add(l2.Deal__c);
                }
                if(l2.Participated__c == TRUE){
                    participatedDeals.add(l2.Deal__c);
                }
            }
            deals = [Select Id, Consumer_Loan__c,Consumer_Loan_Hidden__c, Participated_Loan__c from Opportunity where Id in :dealMap.keySet()]; 
            for (Opportunity o : deals){
                if(consumerDeals.contains(o.Id)){
                    o.Consumer_Loan__c = TRUE;
                    o.Consumer_Loan_Hidden__c = FALSE;
                }else{
                    o.Consumer_Loan__c = FALSE;
                }
                if(consumerDealsYellow.contains(o.Id)){
                    o.Consumer_Loan_Hidden__c = TRUE;
                }else{
                    o.Consumer_Loan_Hidden__c = FALSE;
                }
                if(participatedDeals.contains(o.Id)){
                    o.Participated_Loan__c = TRUE;
                }else{
                    o.Participated_Loan__c = FALSE;
                }
                updatedDeals.add(o);
            }
            if(updatedDeals.size()>0){
                update updatedDeals;
            }
        }
    }
In the code below, I am trying to figure out a way If Consumer_Loan__c = TRUE then it will require Consumer_Loan_Hidden__c = FALSE. 

I appreciate your help



deals = [Select Id, Consumer_Loan__c,Consumer_Loan_Hidden__c, Participated_Loan__c from Opportunity where Id in :dealMap.keySet()]; 
            for (Opportunity o : deals){
                if(consumerDeals.contains(o.Id)){
                    o.Consumer_Loan__c = TRUE;
                }else{
                    o.Consumer_Loan__c = FALSE;
                }
                if(consumerDealsYellow.contains(o.Id)){
                    o.Consumer_Loan_Hidden__c = TRUE;
                }else{
                    o.Consumer_Loan_Hidden__c = FALSE;
                }
                if(participatedDeals.contains(o.Id)){
                    o.Participated_Loan__c = TRUE;
                }else{
                    o.Participated_Loan__c = FALSE;
                }
                updatedDeals.add(o);
All,

I need help with Line 28, view below

User-added image

Am I writing my expression incorrectly?
All

I am kind of new to Apex coding and I was wondering if anyone could help me with the updating the apex trigger below my Request.

In the Consumer__c picklist field in the Loan__c custom object, contains the values
  •  Not reviewed
  •  Consumer
  •  Non-consumer
  •  Insufficient information 
  • Ambiguous
  •  
  • Request 1: When a user selects “Non-consumer” in the Consumer__c picklist field in the Loan__c object , in the Opportunity object, the Consumer_Loan__c checkbox  = TRUE and the Consumer_Loan_Hidden__c = FALSE. If “Non-consumer” in the Consumer__c picklist field in the Loan__c object is not selected and save , then Consumer_Loan__c checkbox  = FALSE
 
Request 2: When a user selects “Ambiguous”, “'Insufficient information”, or picklist is blank with no value,  in the Consumer__c picklist field in Loan__c object , in the Opportunity object, the Consumer_Loan_Hidden__c checkbox  = TRUE.  If “Ambiguous”, “'Insufficient information”, or picklist is blank with no value,  in the Consumer__c picklist field in Loan__c object is not selected or save, then Consumer_Loan_Hidden__c checkbox  = FALSE


trigger updateDealWithLoanInfo2 on Loan__c (after insert, after update) {
    if(Trigger.isAfter && ( Trigger.isInsert || Trigger.isUpdate )) {
        map<id,id> dealMap = new map<id,id>();
        set<id> consumerDeals = new set<id>();
        set<id> consumerDeals2 = new set<id>();
        set<id> participatedDeals = new set<id>();
        list<Loan__c> loans = new List<Loan__c>(); 
        list<Opportunity> deals = new List<Opportunity>(); 
        list<Opportunity> updatedDeals = new List<Opportunity>(); 
 
        for(Loan__c l : Trigger.new) {
            if(l.Deal__c <> NULL) {
                dealMap.put(l.Deal__c, l.Id);
            }
        }
        if(dealMap.size()>0){
            loans = [Select Deal__c, Consumer__c, Participated__c from Loan__c where Deal__c in :dealMap.keySet()];
            for (Loan__c l2 : loans){
                if(l2.Consumer__c != 'Non-consumer'){
                    consumerDeals.add(l2.Deal__c);
                }
                if(l2.Consumer__c != 'Ambiguous' && l2.Consumer__c != 'Insufficient information' && l2.Consumer__c != null ){
                    consumerDeals2.add(l2.Deal__c);
                }
                if(l2.Participated__c == TRUE){
                    participatedDeals.add(l2.Deal__c);
                }
            }
            deals = [Select Id, Consumer_Loan__c, Consumer_Loan_Hidden__c,  Participated_Loan__c from Opportunity where Id in :dealMap.keySet()];
            for (Opportunity o : deals){
                if(consumerDeals.contains(o.Id)){
                    o.Consumer_Loan__c = TRUE;
                }else{
                    o.Consumer_Loan__c = FALSE;
                }
                 if(consumerDeals2.contains(o.Id)){
                    o.Consumer_Loan_Hidden__c = TRUE;
                }else{
                    o.Consumer_Loan_Hidden__c = FALSE;
                }
                if(participatedDeals.contains(o.Id)){
                    o.Participated_Loan__c = TRUE;
                }else{
                    o.Participated_Loan__c = FALSE;
                }
                updatedDeals.add(o);
            }
            if(updatedDeals.size()>0){
                update updatedDeals;
            }
        }
    }
}


I appreciate your help on this
All

I am kind of new to Apex coding and I was wondering if anyone could help me with the updating the apex trigger I have saved as an images.I had to save the coding in images because of the new Text limit feature by SF.

In the Consumer__c picklist field in the Loan__c custom object, contains the values
 
  •  Not reviewed
  •  Consumer
  •  Non-consumer
  •  Insufficient information
  • Ambiguous 
  •  
  • Request 1: When a user selects “Non-consumer” in the Consumer__c picklist field in the Loan__c object , in the Opportunity object, the Consumer_Loan__c checkbox  = TRUE and the Consumer_Loan_Hidden__c = FALSE
 
Request 2: When a user selects “Ambiguous”, “'Insufficient information”, or picklist is blank with no value,  in the Consumer__c picklist field in Loan__c object , in the Opportunity object, the Consumer_Loan_Hidden__c checkbox  = TRUE.

User-added image
User-added image
All,

I need some help with some Apex coding since I am a beginner and I appreciate all help. I have tried to modfiy the coding completed by another developer but it is not working.

below are the object and fields that will be involved with the trigger

Object
Opportunities

Field 
Engagement_Total_Fees__c  (Currency(16, 2) - label name Engagement

Custom Object
Matter__c

Fields
Total_Fees__c    (Currency(16, 2) 
Deal__c  Lookup(Opportunity) 

Schema below - Lookup relationship from Matters__c (object label Engagement)
User-added image

Request.

When a  record is updated, created, or deleted in the Total_Fees__c field in Matter__c object, I want a total sum in Total_Fees__c field to be inserted in the Engagement_Total_Fees__c field within the related Opportunity.

Will it best to place this trigger in Opportunities Or Matter__c object? 

I appreciate all of your help.

Regards


 
All,

I would appreciate some help on an Apex Trigger I am trying to create on Opportunities. I am kind of new in Apex trigger coding so I would really appreciate your help.

Below are objects with the following fields

Settlement__c  (custom Object)
  • Recovery_Total__c  - Formula (Currency) field with formula -  Initial_Value__c - Book_Value__c 
Matter__c (custom Object)
  • Total_Fees__c - Currency(16, 2) field 
Opportunities
  • Settlement_Recovery_Total__c - Currency(16, 2) field
  • Engagement_Total_Fees__c - Currency(16, 2) field 
There is a lookup relationship from Settlement__c  to Opportunities and another lookup relationship from Matter__c  to Opportunities.

What I was trying to figure out is how to sum the total records from the Total_Fees__c  field in Matter__c into the Settlement_Recovery_Total__c in Opportunities . Also sum the total records from the Recovery_Total__c  in Settlement__c  to the Settlement_Recovery_Total__c in Opportunities.

These total sums are for related records only between the objects.

Once this trigger is created, I will have a better understanding of creating other cross object triggers in the future.

I would really appreciate your help.
All,

I am here seeking help for Apex Trigger coding. 

In the User Object I created a Custom Picklist field name Asset_Manager_Group__c with the values Group A, Group B, Group C, Group D

In Opportunities, I created another Custon Picklist field name Asset_Manager_Group__c with the values Group A, Group B, Group C, Group D

Apex Trigger Request - I am requesting if someone can help me create a trigger.  When an administrator selects a value in the Asset_Manager_Group__c in the User Object and saves the record, the same value will automatically populate in the Asset_Manager_Group__c field in the associated opportunity record based on Opportunity owner. For example if Asset_Manager_Group__c = Group A in Joh Doe User object, the related Opportunity records own by John Doe will have the same value in the Asset_Manager_Group__c field.


I really appreciate the help. Thank you.
 
All,
 
I am requesting for assistance with a cross object trigger that I have been struggling to create. This is my first attempt in creating a Cross object trigger and I would appreciate any assistance.
 
Below are the names of the objects and fields.
 
In the Judgment_Event__c I have the following fields below.
 
Action_Type__c                    (picklist)
 
Recording_Location__c          (picklist)
 
Expiration_Date__c                (date)
 
Recording_Date__c                 (date)
 
Recording_Office_State__c   (Picklist)
 
 
Below are fields I have in the Judgment_Exp_Matrix__c object.
 
Years__c       (Number)
State1__c      Lookup(State)
 
 
MY REQUEST BELOW
 
In my trigger within the Judgment_Event__c ,   when a user selects Action_Type__c  = = ‘Recording’
And  Recording_Location__c   = = ‘County’
And  Recording_Office_State__c ==’a state that user chose  from a picklist’ (example if someone selects California)
 
AND
 
In Judgment_Exp_Matrix__c when a user selects a number in the Years__c and a state within the State1__c (example: this has to be the same state in the Recording_Office_State__c in Judgment_Event__c  ). I would like the number in  Years__c to add with the date in Recording_Date__c in Judgment_Event__c , and the final calculation will be automatically populate in the Expiration_Date__c.  For example: if the date in the Recording_Date__c is 1/01/2012 and a user selects the number 2 in the Years__c field, 1/01/2014 will be automatically populated in the Expiration_Date__c .
 
Note: Just a reminder, in the Judgment_Event__c object, the State in the Recording_Office_State__c has to be the same state in the  State1__c in Judgment_Exp_Matrix__c . If the state values are not the same in both fields, then the trigger should not initiate.
 
Below is the only coding I have currently which is not much.
 
trigger NewYear on Judgment_Event__c (before insert,before update) {
    for(Judgment_Event__c JE: Trigger.new){
        if(je.Action_Type__c == 'Recording' && je.Recording_Location__c == 'County') {
    }
}

Regards,
All,
 
I am requesting for some assistance with a trigger I am trying to create within my custom object name  Judgment_Event__c .
 
In the Judgment_Event__c I have the following fields below.
 
Action_Type__c                  (picklist)
 
Recording_Location__c     (picklist)
 
Expiration_Date__c            (date)
 
Recording_Date__c             (date)
 
Years__c                                (Number)
 
 
In my Trigger when Action_Type__c  = = ‘Recording’
And when Recording_Location__c   = = ‘County’
 
When a user enters a value in the Years__c field, I would like the number to be automatically be added to the date in the Recording_Date__c and the final calculation will be automatically populated in the Expiration_Date__c. This will happens whenever a user creates a new record or edits the information.

Below are the coding that I have for now, it is not much since I am a beginner in Apex.

User-added image

your help will be greatly appreciated.
 
All ,

This is my first attempt in creating a trigger.

I have 2 date fields (below) in a custom object name Judgment_Event__c

Expiration_Date__c
Recording_Date__c

When I attempted to write my trigger below, I received the error.

User-added image
I want a trigger to initiate when a user enters or edits the Recording_Date__c the same date value will automatically populate into the Expiration_Date__c . This could be easily done with a formula field, however I am trying to learn how to code using triggers.

Regards,
I am requesting if anyone could help me with a requirement. When someone enters a Date in the custom field Date_Dissolution__c within the Accounts object. I want the words "Date of Dissolution Entered" in the top right of the page layout. (view logo below).

User-added image

Can this be done by creating a visual force page? 

I am to Visual Foce and I just started exploring it today and I appreciate the help.

Forrest


Hi Guys,
I Have a Requirement Using Trigger When a account record inserted or  updated need to display all contacts associated with that account
can anyone help me out if possible send me code.
Thanks & Regards
trigger should work for after insert , after update, after delete, after undelete 
 Thanks  in advance
All,
 
I woul appreciate any help with my requirement below .  I am kind of new in coding and I would appreciate any assitance

REQUIREMENT
 
When Opportunity record is connected to one or more Matter__c  record, Sum all currency values in the Total_Fees__c currency field and add Sum total value in the Engagement_Total_Fees__c field in the related Opportunity record
 
OBJECTS
Opportunity (parent object)
Matter__c  (Child object) custom object.
 
 
OPPORTUNITY FIELD
Engagement_Total_Fees__c - currency (16,2) custom field
 
MATTER__C field
Total_Fees__c - currency (16,2) custom field
Deal__c  - Lookup(Opportunity) custom field
 

WHAT I HAD DONE
 
Below is a trigger I created based on website https://github.com/abhinavguptas/Salesforce-Lookup-Rollup-Summaries .
 
I am requesting if you can review my code because I received the error below
 
“Error: Compile Error: Invalid type: LREngine.Context at line 26 column 33”
 The data on line 26 is “LREngine.Context ctx = new LREngine.Context(Opportunity.SobjectType, // parent object

Trigger Below

/* Updated version on 17 June 16

*/

trigger OppRollupOnEngagement on Matter__c (after insert, after update, 
                                        after delete, after undelete) 

// modified objects whose parent records should be updated
     {Matter__c[] objects = null;

if (Trigger.isDelete) {
         objects = Trigger.old;

 /*
      Handle any filtering required, specially on Trigger.isUpdate event. If the rolled up fields
      are not changed, then please make sure you skip the rollup operation.
      We are not adding that for sake of similicity of this illustration.
 */ 
        objects = Trigger.new;
     }

/*
      First step is to create a context for LREngine, by specifying parent and child objects and
      lookup relationship field name
*/
     LREngine.Context ctx = new LREngine.Context(Opportunity.SobjectType, // parent object
                                            Matter__c.SobjectType,  // child object
                                            Schema.SObjectType.Matter__c.fields.Deal__c // relationship field name
                                            ); 

/*
      Next, one can add multiple rollup fields on the above relationship. 
      Here specify 
       1. The field to aggregate in child object
       2. The field to which aggregated value will be saved in master/parent object
       3. The aggregate operation to be done i.e. SUM, AVG, COUNT, MIN/MAX
*/

ctx.add(
            new LREngine.RollupSummaryField(
                                            Schema.SObjectType.Opportunity.fields.Engagement_Total_Fees__c,
                                            Schema.SObjectType.Matter__c.fields.Total_Fees__c,
                                            LREngine.RollupOperation.Sum 
                                         )); 
/* 
      Calling rollup method returns in memory master objects with aggregated values in them. 
      Please note these master records are not persisted back, so that client gets a chance 
      to post process them after rollup
*/ 

Sobject[] masters = LREngine.rollUp(ctx, objects);    

     // Persiste the changes in master
     update masters;

}



I would appreciate the help . 
 
All,

I have a custom object Matter__c  label is Engagement with a lookup relationship field Deal__c  datatype Lookup(Opportunity) that connects to Opportunity. Opportunities object in my Salesforce database is rename to Deal__c  .
 
I am requesting if the currency value in the custom currency (16,2)  field Total_Fees__c in the custom object  Matter__c which may contain one or more records ,  will Rollup Summary into the related Opportunity ( Deal__c ) record,   within the custom currency (16,2) field Engagement_Total_Fees__c .  For each Deal__c record there can be one or  many Matter__c  records.
 
I created a Trigger below but it is not working. I believe the trigger does not have coding that will place the currency values in the Total_Fees__c field in Matter__c records to be summarize in the Engagement_Total_Fees__c in the Deal__c record.
 
I am not an expert in triggers and I could appreciate the help.

trigger UpdateEngagementTotalFees on Matter__c (After insert,After update,After delete){
    Set<String>dealIds= new Set<String>();
    if(Trigger.isDelete){
        for(Matter__c mat : Trigger.old){
            dealIds.add(mat.Deal__c);
        }
    }else if(Trigger.isUpdate){
       for(Matter__c mat : Trigger.New){
            if(mat.Deal__c != trigger.oldMap.get(mat.id).Deal__c || mat.Total_Fees__c !=trigger.oldMap.get(mat.id).Total_Fees__c){
                if(mat.Deal__c!=null)
                    dealIds.add(mat.Deal__c);
                if(trigger.oldMap.get(mat.id).Deal__c!=null)
                  dealIds.add(trigger.oldMap.get(mat.id).Deal__c);  
            }
       } 
    }else{
        for(Matter__c mat : Trigger.New){
            if(mat.Deal__c != null){
                dealIds.add(mat.Deal__c);
            }
        }
    }
    if(dealIds.size()>0){
        TriggerUtility.rollupBookValues(dealIds,'Matter__c');
    }
    }
 
All,

I created an Apex Trigger below, but I assume it is firing after a user selects the "Submit" button. I would like for this trigger to fire after someone selects either the " Approve " button or " Reject " button.

I would appreciate your help 




trigger TriggerApprover on Matter__c (before update) {
   
       if(trigger.isUpdate){
             List<Matter__c> MatterList =  [Select id,
                                                   (Select Id,
                                                         IsPending,
                                                         ProcessInstanceId,
                                                         TargetObjectId,
                                                         StepStatus,
                                                         OriginalActorId,
                                                         ActorId,
                                                         RemindersSent,
                                                         Comments,
                                                         IsDeleted,
                                                         CreatedDate,
                                                         CreatedById,
                                                         SystemModstamp
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC)
                                                    From Matter__c
                                                WHERE Id IN : Trigger.new];
 
             if(MatterList.size() > 0){
 
               for(Matter__c mat : MatterList){
             
                for(Matter__c mat1 : Trigger.new) {
                 
                         //check copy comment is true
                         if(mat.id == mat1.id && mat1.Copy_Comment__c) {
 
                           if (mat.ProcessSteps.size() > 0) {
                           
                         mat1.Approver_Comment__c = mat.ProcessSteps[0].Comments;
                         mat1.copy_comment__c = false;
               
                           }
 
                        }
                
                    }
               }
             }  
        } 
    }
 
All,

I created a trigger ( view below)  that will take values from  the Comments field when an Approver either Approves or Rejects a record, the values in the comment field  will then be inserted in the  Approver_Comment__c long text field located in the  matter__c custom object. However, When I created an email alert for the Final Approval Actions and Final Rejection Actions in the Approval Process, the email does not send me the current information in the Approver_Comment__c in the matter__c custom object, it only sends me the older value. Example if value "Test 1" already exist in the Approver_Comment__c and the approver approves the same record and writes "Test 2" in the Comments fieldd before approving or rejecting the record, after the approver selects the Approve or Reject button, the value "Test 1"  will be send in the email alert , not the value "Test 2". I appreciate the help. I want the most current value in the comments field which in this siutation  is "Test 2" to be sent via the email alert. 

I could appreciate it if someone could assist me on this. 
 
 
trigger TriggerApprover on Matter__c (before update) {
   
       if(trigger.isUpdate){
             List<Matter__c> MatterList =  [Select id,
                                                   (Select Id,
                                                         IsPending,
                                                         ProcessInstanceId,
                                                         TargetObjectId,
                                                         StepStatus,
                                                         OriginalActorId,
                                                         ActorId,
                                                         RemindersSent,
                                                         Comments,
                                                         IsDeleted,
                                                         CreatedDate,
                                                         CreatedById,
                                                         SystemModstamp
                                                    FROM ProcessSteps
                                                ORDER BY CreatedDate DESC)
                                                    From Matter__c
                                                WHERE Id IN : Trigger.new];
 
             if(MatterList.size() > 0){
 
               for(Matter__c mat : MatterList){
             
                for(Matter__c mat1 : Trigger.new) {
                 
                         //check copy comment is true
                         if(mat.id == mat1.id && mat1.Copy_Comment__c) {
 
                           if (mat.ProcessSteps.size() > 0) {
                           
                         mat1.Approver_Comment__c = mat.ProcessSteps[0].Comments;
                         mat1.copy_comment__c = false;
               
                           }
 
                        }
                
                    }
               }
             }  
        } 
    }
 
All,

Within my Inbound Change Sets in my production Instance, I did a Validation to my change set and I received the results below

User-added image

User-added image

Does anyone have any recommendations how I can fix these issues?  

Can I successfuly Deploy this change set ?

This is my first time migrating information from my sandbox to production and any help will be greatly appreciated.

Regards,
Is there a way to update a custom field on a the opportunity record with the approval comments from the fina approver?

 
All,

I have a one to many relationship between Opportunities and a custom object name Loan__c (one Opportunity to many Loan__c). When I delete a loan record, my trigger below does not fire. 

Does anyone know how to update this code so that when I delete a loan record, the trigger will fire?

Trigger updateDealWithLoanInfo2 on Loan__c (after insert, after update) {
    if(Trigger.isAfter && ( Trigger.isInsert || Trigger.isUpdate )) {
        map<id,id> dealMap = new map<id,id>();
        set<id> consumerDeals = new set<id>();
        set<id> consumerDealsYellow = new set<id>();
        set<id> participatedDeals = new set<id>();
        list<Loan__c> loans = new List<Loan__c>();  
        list<Opportunity> deals = new List<Opportunity>();  
        list<Opportunity> updatedDeals = new List<Opportunity>();  

        for(Loan__c l : Trigger.new) {
            if(l.Deal__c <> NULL) {
                dealMap.put(l.Deal__c, l.Id);
            }
        }
        if(dealMap.size()>0){
            loans = [Select Deal__c, Consumer__c, Participated__c from Loan__c where Deal__c in :dealMap.keySet()];
            for (Loan__c l2 : loans){
                if(l2.Consumer__c == 'Consumer'){
                    consumerDeals.add(l2.Deal__c);
                }
                if(l2.Consumer__c == 'Ambiguous' || l2.Consumer__c == NULL || l2.Consumer__c == 'Insufficient information'|| l2.Consumer__c == 'Not reviewed'){
                    consumerDealsYellow.add(l2.Deal__c);
                }
                if(l2.Participated__c == TRUE){
                    participatedDeals.add(l2.Deal__c);
                }
            }
            deals = [Select Id, Consumer_Loan__c,Consumer_Loan_Hidden__c, Participated_Loan__c from Opportunity where Id in :dealMap.keySet()]; 
            for (Opportunity o : deals){
                if(consumerDeals.contains(o.Id)){
                    o.Consumer_Loan__c = TRUE;
                    o.Consumer_Loan_Hidden__c = FALSE;
                }else{
                    o.Consumer_Loan__c = FALSE;
                }
                if(consumerDealsYellow.contains(o.Id)){
                    o.Consumer_Loan_Hidden__c = TRUE;
                }else{
                    o.Consumer_Loan_Hidden__c = FALSE;
                }
                if(participatedDeals.contains(o.Id)){
                    o.Participated_Loan__c = TRUE;
                }else{
                    o.Participated_Loan__c = FALSE;
                }
                updatedDeals.add(o);
            }
            if(updatedDeals.size()>0){
                update updatedDeals;
            }
        }
    }
In the code below, I am trying to figure out a way If Consumer_Loan__c = TRUE then it will require Consumer_Loan_Hidden__c = FALSE. 

I appreciate your help



deals = [Select Id, Consumer_Loan__c,Consumer_Loan_Hidden__c, Participated_Loan__c from Opportunity where Id in :dealMap.keySet()]; 
            for (Opportunity o : deals){
                if(consumerDeals.contains(o.Id)){
                    o.Consumer_Loan__c = TRUE;
                }else{
                    o.Consumer_Loan__c = FALSE;
                }
                if(consumerDealsYellow.contains(o.Id)){
                    o.Consumer_Loan_Hidden__c = TRUE;
                }else{
                    o.Consumer_Loan_Hidden__c = FALSE;
                }
                if(participatedDeals.contains(o.Id)){
                    o.Participated_Loan__c = TRUE;
                }else{
                    o.Participated_Loan__c = FALSE;
                }
                updatedDeals.add(o);
All,

I need help with Line 28, view below

User-added image

Am I writing my expression incorrectly?
All

I am kind of new to Apex coding and I was wondering if anyone could help me with the updating the apex trigger below my Request.

In the Consumer__c picklist field in the Loan__c custom object, contains the values
  •  Not reviewed
  •  Consumer
  •  Non-consumer
  •  Insufficient information 
  • Ambiguous
  •  
  • Request 1: When a user selects “Non-consumer” in the Consumer__c picklist field in the Loan__c object , in the Opportunity object, the Consumer_Loan__c checkbox  = TRUE and the Consumer_Loan_Hidden__c = FALSE. If “Non-consumer” in the Consumer__c picklist field in the Loan__c object is not selected and save , then Consumer_Loan__c checkbox  = FALSE
 
Request 2: When a user selects “Ambiguous”, “'Insufficient information”, or picklist is blank with no value,  in the Consumer__c picklist field in Loan__c object , in the Opportunity object, the Consumer_Loan_Hidden__c checkbox  = TRUE.  If “Ambiguous”, “'Insufficient information”, or picklist is blank with no value,  in the Consumer__c picklist field in Loan__c object is not selected or save, then Consumer_Loan_Hidden__c checkbox  = FALSE


trigger updateDealWithLoanInfo2 on Loan__c (after insert, after update) {
    if(Trigger.isAfter && ( Trigger.isInsert || Trigger.isUpdate )) {
        map<id,id> dealMap = new map<id,id>();
        set<id> consumerDeals = new set<id>();
        set<id> consumerDeals2 = new set<id>();
        set<id> participatedDeals = new set<id>();
        list<Loan__c> loans = new List<Loan__c>(); 
        list<Opportunity> deals = new List<Opportunity>(); 
        list<Opportunity> updatedDeals = new List<Opportunity>(); 
 
        for(Loan__c l : Trigger.new) {
            if(l.Deal__c <> NULL) {
                dealMap.put(l.Deal__c, l.Id);
            }
        }
        if(dealMap.size()>0){
            loans = [Select Deal__c, Consumer__c, Participated__c from Loan__c where Deal__c in :dealMap.keySet()];
            for (Loan__c l2 : loans){
                if(l2.Consumer__c != 'Non-consumer'){
                    consumerDeals.add(l2.Deal__c);
                }
                if(l2.Consumer__c != 'Ambiguous' && l2.Consumer__c != 'Insufficient information' && l2.Consumer__c != null ){
                    consumerDeals2.add(l2.Deal__c);
                }
                if(l2.Participated__c == TRUE){
                    participatedDeals.add(l2.Deal__c);
                }
            }
            deals = [Select Id, Consumer_Loan__c, Consumer_Loan_Hidden__c,  Participated_Loan__c from Opportunity where Id in :dealMap.keySet()];
            for (Opportunity o : deals){
                if(consumerDeals.contains(o.Id)){
                    o.Consumer_Loan__c = TRUE;
                }else{
                    o.Consumer_Loan__c = FALSE;
                }
                 if(consumerDeals2.contains(o.Id)){
                    o.Consumer_Loan_Hidden__c = TRUE;
                }else{
                    o.Consumer_Loan_Hidden__c = FALSE;
                }
                if(participatedDeals.contains(o.Id)){
                    o.Participated_Loan__c = TRUE;
                }else{
                    o.Participated_Loan__c = FALSE;
                }
                updatedDeals.add(o);
            }
            if(updatedDeals.size()>0){
                update updatedDeals;
            }
        }
    }
}


I appreciate your help on this