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
hamshuhamshu 

concatenate value in a set

HI,

 

Any One Came accross like this

 

trigger DuplicateLead on lead (before insert,before update)
{
 
         Set<string> lastname= new Set<string>();
   
      
        for(lead lead : Trigger.new)
         {
             string getjoin=lead .firstname+' '+lead .lastname;
              system.debug(getjoin);output=Sam Kumar
             lastname.add(getjoin );
             system.debug(getjoin);OutPUT:{Sam Kumar} Why ? And How to remove this
         }

}

 

Thanks,

Jaba

ManojjenaManojjena

Hey it is the general structure of Set. As you are adding in set that is why it showing in this format.

 

You can use this code out side the loop to replace

 

String str=String.valueOf(lastName);
          str.replace('{','');
          str.replace('}','');

 

I think it will help you .

hamshuhamshu

Hi situ,

 

Thanks for your replay

 

Still i am not able to remove { and } after using Replace function too.

 

 

 

Thanks,

jaba

ManojjenaManojjena

hey try this it will work 


String str=String.valueOf(lastName);
String sttr=str.substring(1,str.length()-1);