function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SuAkSuAk 

update a text without deleting the previous value (Just append the value)

Hi All - Please view the below method, I want to update the Package member value in Package object with the value in the member value field + Name tag from Deployment Item object.
If there are more than one deployment item records are assocaited with the Package, it just updates it with last processed record of the Deployment item records.
I would want to populate the member value from all the deployment item records associated with the package, to the Package member value field.
Help me to proceed further.
Thanks!
***************************************************************************************************************************************************
public PageReference UpdateMembervalue(){
       
     List<Deployment_Item__c> DIList =  [SELECT Member_Value__c,Name_tag__c,Additional_Instructions__c,
                                                Component_API_Name__c,Created_Date__c,Defect_WI__c,Deployment_Type__c,
                                             Environment__c,Metadata_Type__c,Object_API_Name__c,Package_Name__c
                                         FROM   Deployment_Item__c
                                         WHERE  Created_Date__c = Today
                                         AND Deployment_Status__c = 'Waiting for Deployment'];
       
             List<Package__c> PAList =  [SELECT Id,Deployed_By__c, Deployed_Date__c,Package_Member_Value__c,Created_Date__c,Name
                                         FROM   Package__c
                                         WHERE  Created_Date__c = Today
                                         AND  Deployment_Status__c!= 'Deployed'
                                         LIMIT 1];
            AggregateResult[] results =  [SELECT Name_tag__c, Count(Member_Value__c) 
                                          FROM   Deployment_Item__c
                                          WHERE  Created_Date__c = Today
                                          AND    Deployment_Status__c = 'Waiting for Deployment'
                                          GROUP BY Name_tag__c ];
       
        Package__C Pack = PAList[0];
        system.debug('Inside this method');
        for(Deployment_Item__c DIrec : DIList){
                                    system.debug('drec>>>>>>'+DIrec);
                  Pack.Package_Member_Value__c = DIrec.Member_Value__c + DIrec.Name_tag__c;
                                                    
                                    update Pack;
                       
        system.debug ('DIList' +results);    
        }
      PageReference pageRef = new PageReference('/a6P/o');
      pageRef.setRedirect(true);
      return pageRef;
    }
    }                               
*******************************************************************************************************************************************************