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
srikanth11srikanth11 

list id's help

i have 2 queries and i bought the id of the two queries into two variables now i want them both in one variable how can i do that 

 

 

   workItemListstep = [Select  p.ProcessInstance.TargetObjectId,p.ProcessInstanceId,p.OriginalActorId,p.Id,p.ActorId,p.Actor.name From ProcessInstancestep p where p.ProcessInstance.TargetObjectId = :ID ];         
     workItemListitem = [Select  p.ProcessInstance.TargetObjectId,p.ProcessInstanceId,p.OriginalActorId,p.Id,p.ActorId,p.Actor.name From ProcessInstanceworkitem p where p.ProcessInstance.TargetObjectId = :ID ];     
     
     
     set<id> ff=new set<id>();
     for(ProcessInstancestep workItemListstep1:workItemListstep)
     {
     ff.add(workItemListstep1.id);
       }
       
     set<id> ff1=new set<id>();
     
     for(ProcessInstanceworkitem workItemListitem1:workItemListitem)
     {
    
   
     ff1.add(workItemListitem1.id);    
     }
here i bought the id's into two different sets now i want all these id's into 1 set how can i do that plz help

 

Best Answer chosen by Admin (Salesforce Developers) 
AmitSahuAmitSahu

You can use Set.addAll method. s1 is a set s2 is a set then take s3 and try s3.addall(s1) and s3.addAll(s2).

 

Example: 

set<string> myString =
   new Set<String>{'a', 'b'};
set<string> sString =
   new Set<String>{'c'};
set<string> s1= new Set<String>();
s1.addall(myString);
s1.addAll(sString);

 

System.Debug(s1);

 

Hope that helps..

 

Regards,

 

J

All Answers

AmitSahuAmitSahu

You can use Set.addAll method. s1 is a set s2 is a set then take s3 and try s3.addall(s1) and s3.addAll(s2).

 

Example: 

set<string> myString =
   new Set<String>{'a', 'b'};
set<string> sString =
   new Set<String>{'c'};
set<string> s1= new Set<String>();
s1.addall(myString);
s1.addAll(sString);

 

System.Debug(s1);

 

Hope that helps..

 

Regards,

 

J

This was selected as the best answer
srikanth11srikanth11

hi jo 

 

thanks for u r reply but its a bit confusing can u apply it to my code and rewrite it please jo

srikanth11srikanth11

soory in the beginning i was a bit confused but now i got it and its working that a great help