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
GMASJGMASJ 

How to add different set values into one set

Hi, 

  How to add in one SET I have two different methods which returns value I am not able to add in one SET so creating two different SET

 set<id> actchl = new set<id>(AccountHierarchyUtil.ChildToParnet(AccountID));
 set<id> actpar = new set<id>(AccountHierarchyUtil.ParnetToChild(AccountID));

Please suggest me how to add in one SET

Thanks
Sudhir
Best Answer chosen by GMASJ
v varaprasadv varaprasad
Hi Sudhir,

addAll method results in the union of the two sets. The specified set must be of the same type as the original set that calls the method.

 
set<id> actchl = new set<id>(AccountHierarchyUtil.ChildToParnet(AccountID));
 set<id> actpar = new set<id>(AccountHierarchyUtil.ParnetToChild(AccountID));

actchl.addAll(actpar);

system.debug('==actchl==:'+actchl);

Hope this helps you!

Thanks
Varaprasad
For Support: varaprasad4sfdc@gmail.com