• jleeh
  • NEWBIE
  • 35 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 13
    Replies
I need to take a trigger and move it into a class method. The trigger works correctly, but I need to move it into a method and call it from 2nd trigger that is already calling other methods. I'm doing this because I don't want multiple triggers on one object.

What should the method look like?

trigger dealUpdate on Deal_Update__c (before insert)
{
    set<string> bpidSet = new set<string>();

    for (Deal_Update__c spBPID : Trigger.new){
       if(spBPID.Partner_BPID__c!=null) bpidSet.add(spBPID.Partner_BPID__c);
    }

    if(bpidSet.size()>0){
       List<Account> accountList = [SELECT Id, SP_BPD__c FROM Account
                                    WHERE SP_BPD__c = :bpidSet AND IsPersonAccount=FALSE
                                    AND RecordType.DeveloperName='Partner_Account'];

       Map<string,id> accountmap = new Map<string,id>();

       for (Account a : accountList) {
          accountmap.put(a.SP_BPID__c,a.id);
       }

        for (Deal_Update__c spBPID : Trigger.new){

          if(accountmap != null) {
              spBPID.Partner_Account__c = accountmap.get(spBPID.Partner_BPID__c);
          }
        }
    }
}


 
  • June 24, 2016
  • Like
  • 0
Needing help with a simple trigger. I have a value in a custom field on a Custom Object. I want to query Accounts to find the AccountId where the custom field value on my Custom Object = the value of a custom field value on Account. I then want to insert the AccountId into a lookup field on the Custom Object. Help is much appreciated. 

trigger recordUpdate on Custom_Object__c (after insert, after update)
{
    String a = // need to create a variable for the value of a custom_field__c (text) on Custom_Object__c

    List<Id> accountId= [SELECT Id FROM Account WHERE account_custom_field__c = :a];

    insert // not sure how to then insert the value of accountId to a different custom field on Custom_Object__c
}
  • May 05, 2016
  • Like
  • 0
I cannot find the answer anywhere! Does anyone know if I can use Lightning Process Builder to setup multiple time-dependent actions under one "node" (not sure if I'm using "node" in the correct context here). 

What I'm trying to do is:

WHEN XYZ CRITERIA IS MET: After 30 days --> send out this email and make this field update, After 60 days --> send out this different email and make this field update, After 90 days --> send out this different email and perform these other actions. 

I can set this up under one rule using Workflow, but I cannot seem to do this with Process Builder. I can setup one time-depedency rule using Process Builder (After 30 days...), but I cannot figure out how to go about adding the 60 and 90 day rules. 

Help is greatly appreciated!
  • February 16, 2015
  • Like
  • 0
Hi - I've created an SOQL query on the GroupMember object to query for all Queues that a user is not a member of. However, the list populates duplicates. 

Does anyone know if the query can be setup to not display duplicates in my List? I've read that a loop may be possible, but I don't know how I would set it up to remove duplicates.


notqueueresults = new List<GroupMember> ([SELECT ID,Group.Name FROM GroupMember WHERE UserOrGroupId !=: results[0].Id ])

Thanks!
  • September 17, 2014
  • Like
  • 0
I have been looking for hours over the past few weeks for a solution to what I think must be a common issue. My client is requesting that I change a custom object to display two columns (ok, got it) but need headers to designate column 1 as "Standard" and column 2 as "Unique". Ideally, these would be headers within the section. I would prefer to go declarative, but this isn't possible, unless I use the FLS "read-only" trick. The problem with this is that it looks awful, and I need to repeat it for many different sections. I suggest to just go with actual sections labeled differently (much less work), but the client is insistent on utilizing sub-headers. 

Does anyone know this can be accomplished using VF? The only information I can find is in regards to apex:dataTable, but I do not actually need a table, just the layout. 

Note: The image shows only column 1 with a subheader, but need a subheader for both columns. 
User-added image
  • June 30, 2014
  • Like
  • 0

I'm trying to code a trigger to auto-Submit a record through the Approval Process on a Custom Object. I want to do this to make the record Read Only (I know there are others ways to do this, but I'm up for a challenge!). 

 

My Approval Process criteria is only: when "Locked__c" (checkbox) is "True". I also have it set to auto-reject by default and lock the record

 

The code I'm using is below, but I'm receiving error message: 
Error: Compile Error: Variable does not exist: Locked__c at line 3 column 12

 

I'm new to Apex coding, so any help is greatly appreciated! If any other information is needed, just let me know. 

 

trigger Record_Lock on Plan_and_Profile__c (after update, after insert) {
for (Plan_and_Profile__c a: Trigger.new) { 
    if (a.(Locked__c == 'True')) {
      // Create an approval request for the account
      Approval.ProcessSubmitRequest req1 =
      new Approval.ProcessSubmitRequest();
      req1.setComments('Automatic record lock.');
      req1.setObjectID(a.id);
      
      // Submit the approval request for the account
      Approval.ProcessResult result = Approval.process (req1);
    }
  }
}

 

  • November 05, 2013
  • Like
  • 0

Hi all, 

 

I'm very green in terms of VisualForce development, and I have a question regarding linking div's from a VF page to custom objects. I haven't been able to find the answer online because my page is slightly different. I'll explain: 

 

On my VF page, I have created six separate boxes (using div classes). The six boxes give the title of an object and what the object is used for. Essentially, this VF page is acting as my landing page. Each box has a different background color, text, etc. What I need to do is turn the entire box into a link that will take the user to an object I specify. I don't want just words within the box to be the link to the object, but the ENTIRE div box to act as the link. 

 

 

Any help on this would be greatly appreciated. 

  • September 03, 2013
  • Like
  • 0
I need to take a trigger and move it into a class method. The trigger works correctly, but I need to move it into a method and call it from 2nd trigger that is already calling other methods. I'm doing this because I don't want multiple triggers on one object.

What should the method look like?

trigger dealUpdate on Deal_Update__c (before insert)
{
    set<string> bpidSet = new set<string>();

    for (Deal_Update__c spBPID : Trigger.new){
       if(spBPID.Partner_BPID__c!=null) bpidSet.add(spBPID.Partner_BPID__c);
    }

    if(bpidSet.size()>0){
       List<Account> accountList = [SELECT Id, SP_BPD__c FROM Account
                                    WHERE SP_BPD__c = :bpidSet AND IsPersonAccount=FALSE
                                    AND RecordType.DeveloperName='Partner_Account'];

       Map<string,id> accountmap = new Map<string,id>();

       for (Account a : accountList) {
          accountmap.put(a.SP_BPID__c,a.id);
       }

        for (Deal_Update__c spBPID : Trigger.new){

          if(accountmap != null) {
              spBPID.Partner_Account__c = accountmap.get(spBPID.Partner_BPID__c);
          }
        }
    }
}


 
  • June 24, 2016
  • Like
  • 0
Needing help with a simple trigger. I have a value in a custom field on a Custom Object. I want to query Accounts to find the AccountId where the custom field value on my Custom Object = the value of a custom field value on Account. I then want to insert the AccountId into a lookup field on the Custom Object. Help is much appreciated. 

trigger recordUpdate on Custom_Object__c (after insert, after update)
{
    String a = // need to create a variable for the value of a custom_field__c (text) on Custom_Object__c

    List<Id> accountId= [SELECT Id FROM Account WHERE account_custom_field__c = :a];

    insert // not sure how to then insert the value of accountId to a different custom field on Custom_Object__c
}
  • May 05, 2016
  • Like
  • 0
Hi - I've created an SOQL query on the GroupMember object to query for all Queues that a user is not a member of. However, the list populates duplicates. 

Does anyone know if the query can be setup to not display duplicates in my List? I've read that a loop may be possible, but I don't know how I would set it up to remove duplicates.


notqueueresults = new List<GroupMember> ([SELECT ID,Group.Name FROM GroupMember WHERE UserOrGroupId !=: results[0].Id ])

Thanks!
  • September 17, 2014
  • Like
  • 0
I have been looking for hours over the past few weeks for a solution to what I think must be a common issue. My client is requesting that I change a custom object to display two columns (ok, got it) but need headers to designate column 1 as "Standard" and column 2 as "Unique". Ideally, these would be headers within the section. I would prefer to go declarative, but this isn't possible, unless I use the FLS "read-only" trick. The problem with this is that it looks awful, and I need to repeat it for many different sections. I suggest to just go with actual sections labeled differently (much less work), but the client is insistent on utilizing sub-headers. 

Does anyone know this can be accomplished using VF? The only information I can find is in regards to apex:dataTable, but I do not actually need a table, just the layout. 

Note: The image shows only column 1 with a subheader, but need a subheader for both columns. 
User-added image
  • June 30, 2014
  • Like
  • 0

I'm trying to code a trigger to auto-Submit a record through the Approval Process on a Custom Object. I want to do this to make the record Read Only (I know there are others ways to do this, but I'm up for a challenge!). 

 

My Approval Process criteria is only: when "Locked__c" (checkbox) is "True". I also have it set to auto-reject by default and lock the record

 

The code I'm using is below, but I'm receiving error message: 
Error: Compile Error: Variable does not exist: Locked__c at line 3 column 12

 

I'm new to Apex coding, so any help is greatly appreciated! If any other information is needed, just let me know. 

 

trigger Record_Lock on Plan_and_Profile__c (after update, after insert) {
for (Plan_and_Profile__c a: Trigger.new) { 
    if (a.(Locked__c == 'True')) {
      // Create an approval request for the account
      Approval.ProcessSubmitRequest req1 =
      new Approval.ProcessSubmitRequest();
      req1.setComments('Automatic record lock.');
      req1.setObjectID(a.id);
      
      // Submit the approval request for the account
      Approval.ProcessResult result = Approval.process (req1);
    }
  }
}

 

  • November 05, 2013
  • Like
  • 0

Hi all, 

 

I'm very green in terms of VisualForce development, and I have a question regarding linking div's from a VF page to custom objects. I haven't been able to find the answer online because my page is slightly different. I'll explain: 

 

On my VF page, I have created six separate boxes (using div classes). The six boxes give the title of an object and what the object is used for. Essentially, this VF page is acting as my landing page. Each box has a different background color, text, etc. What I need to do is turn the entire box into a link that will take the user to an object I specify. I don't want just words within the box to be the link to the object, but the ENTIRE div box to act as the link. 

 

 

Any help on this would be greatly appreciated. 

  • September 03, 2013
  • Like
  • 0