• KCL
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 5
    Replies
I have a custom object  Area "fields "are: fields are
area rep, area manager

We are using territory management. I am using below 2 queries to get the ids of 
UserTerritory2Association, Territory2Id, and Role_Number__c user name.

For Ex:arearep= arep12, we need to update the area rep name in the new text field in custom object Area

I am using  trigger on the Area custom object we need to use the logic in same trigger.


select id,Name,(select UserId,Id,Territory2Id from UserTerritory2Associations) from user where  isactive=true

SELECT DeveloperName,Id,Name,Role_Number__c FROM Territory2

 
  • May 22, 2020
  • Like
  • 0
I have a custom object to store Comments(mattercomments__c)

The only issue is we have 2 approvers for one Matter__c record. when the first approver writes a comment , the comment does not go into the 
Approver_Comment__c (long text ) field in the custom Matter__c object. When the second or last approver writes a comment, it goes into the Approver_Comment__c (long text ) field in the custom Matter__c object.  

This there a way to modify the code below where when both approver writes a comment, it goes into the Approver_Comment__c (long text ) field in the custom Matter__c object? 
List<Matter__c> matList =  [Select id, Approver_Comments__c,
                                                   (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(matList.size() > 0){
           List<mattercomments__c  > notes_new = new List<mattercomments__c  >();
            for(Matter__c mat : matList){
                for(Matter__c mat1 : newlist) {
               
                //check copy comment is true
                if(mat.id == mat1.id) {
                     if (mat.ProcessSteps.size() > 0) {
                        mat1.Approver_Comments__c  = mat.ProcessSteps[0].Comments;
                     }

                }
                 
                if(mat1.Approver_Comments__c   != mat.Approver_Comments__c   && !mat.ProcessSteps.isEmpty() && (mat.ProcessSteps[0].StepStatus == 'Approved' || mat.ProcessSteps[0].StepStatus == 'Rejected')){
                    notes_new.add(new mattercomments__c  (Matterr__c__c= mat.id, Steps__c =mat.ProcessSteps[0].Comments, Type__c = mat.ProcessSteps[0].StepStatus+' Comments'));     
                    
                 }
                 
                    }
               }
                if(!notes_new.isEmpty()) {            
                        insert notes_new; 

                        } 
             }

 
  • May 14, 2020
  • Like
  • 0
I Have parent Object and child object 

Parent: state
Parent Field: Status(picklist Field): values are:(IN,OUT)
Child :city
Child Field: Yes(Check Box)

Need help in writing a trigger : 

Scenerio:When ever picklist values are changed ex: IN to OUt  or OUT to IN The trigger need to Check the YES filed and immediately and then Uncheck.
 
  • August 06, 2019
  • Like
  • 0
I parent Object and child object 

Parent: state
Parent Field: Status(picklist Field): values are:(IN,OUT)
Child :city
Child Field: Yes(Check Box)

Need help in writing a trigger : 

Scenerio:When ever picklist values are changed ex: IN to OUt  or OUT to IN The trigger need to Check the YES filed and immediately Uncheck.

 
  • August 02, 2019
  • Like
  • 0
how to save opp approval and rejection comments in Opp related list.
  • June 12, 2019
  • Like
  • 0
Give Read/Write Access to Opportunity Members when New new quote is generate for that opportunity.
  • August 06, 2018
  • Like
  • 0
I have one Custom Object in that created 2 Custom Fields 1.Related Account 2. Related Opp. After delecting the Opp through lookup in  second field how to pull Acount record related to that opportunity in first field.
  • July 21, 2018
  • Like
  • 0
trigger EST on Development_Item__c (before insert, before update, after update) {

map<ID,string> releasemap=new map<ID,string>();
for( Development_Item__c di:Trigger.new)
    {
        if(trigger.isbefore)
        {
            if(trigger.isinsert)
            {
                if(di.Sign_off_Date__c!=null)    
                {    
                    di.Status__c='Ready for PROD';
                }
                if(di.Business_Ananlyst__c==null)
                {
                    di.adderror('Pls select BA');
                }
            }
            else if(trigger.isupdate)
            {
                if(di.Sign_off_Date__c==null && trigger.isbefore )
                {
                    di.Status__c='In UAT';
                }   
            }
            di.Estimated_QA_hrs__c=0.4*di.Estimated_QA_hrs__c;
    }
    if(trigger.isafter)
        {
            system.debug(' debug is ' + di.name );
            releasemap.put(di.Release__c,di.Name);
        } 
    }
        list<release__c> releaselist=new list<release__c>();
        releaselist=[select id,name,Latest_Updated_Dev_Item__c from release__c where id in: releasemap.keyset() ];
        system.debug('release is' + releaselist);
        for(release__c DE:releaselist)
        {
            DE.Latest_Updated_Dev_Item__c=releasemap.get(DE.ID);
        } 
        update releaselist;
}


THIS IS MY ORIGINAL CODE.
1. Update your trigger logic to use Database.update and set allornone to false.
2. Iterate through the save result, collect all the errors and store the error into the Error Log object. Collect release record id that has the error and the error message. 
3.User-added imageInsert the errors into error log object
  • November 02, 2017
  • Like
  • 0
I have created 2 objects REL and DEV, REL is parent and DEV is the child with master details relationship. I create the   REL1 and DEV1,DEV2 , DEV3. these 3 DEV records are under REL1. DEV 1 one filed that is last modified record name.

Here If i made any update or new record on these DEV items , that should be displayed on REL1, 
 
  • October 31, 2017
  • Like
  • 0
I have a custom object to store Comments(mattercomments__c)

The only issue is we have 2 approvers for one Matter__c record. when the first approver writes a comment , the comment does not go into the 
Approver_Comment__c (long text ) field in the custom Matter__c object. When the second or last approver writes a comment, it goes into the Approver_Comment__c (long text ) field in the custom Matter__c object.  

This there a way to modify the code below where when both approver writes a comment, it goes into the Approver_Comment__c (long text ) field in the custom Matter__c object? 
List<Matter__c> matList =  [Select id, Approver_Comments__c,
                                                   (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(matList.size() > 0){
           List<mattercomments__c  > notes_new = new List<mattercomments__c  >();
            for(Matter__c mat : matList){
                for(Matter__c mat1 : newlist) {
               
                //check copy comment is true
                if(mat.id == mat1.id) {
                     if (mat.ProcessSteps.size() > 0) {
                        mat1.Approver_Comments__c  = mat.ProcessSteps[0].Comments;
                     }

                }
                 
                if(mat1.Approver_Comments__c   != mat.Approver_Comments__c   && !mat.ProcessSteps.isEmpty() && (mat.ProcessSteps[0].StepStatus == 'Approved' || mat.ProcessSteps[0].StepStatus == 'Rejected')){
                    notes_new.add(new mattercomments__c  (Matterr__c__c= mat.id, Steps__c =mat.ProcessSteps[0].Comments, Type__c = mat.ProcessSteps[0].StepStatus+' Comments'));     
                    
                 }
                 
                    }
               }
                if(!notes_new.isEmpty()) {            
                        insert notes_new; 

                        } 
             }

 
  • May 14, 2020
  • Like
  • 0
I have created 2 objects REL and DEV, REL is parent and DEV is the child with master details relationship. I create the   REL1 and DEV1,DEV2 , DEV3. these 3 DEV records are under REL1. DEV 1 one filed that is last modified record name.

Here If i made any update or new record on these DEV items , that should be displayed on REL1, 
 
  • October 31, 2017
  • Like
  • 0
Is there a way to update a custom field on a the opportunity record with the approval comments from the fina approver?