+ Start a Discussion

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.
public PageReference UpdateMembervalue(){
     List<Deployment_Item__c> DIList =  [SELECT Member_Value__c,Name_tag__c,Additional_Instructions__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){
                  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');
      return pageRef;