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
SFDummySFDummy 

insert tab '\t' to string

I am not able to add tab the sting I created

 

Notice the tab I want to insert between the old valud and new value in the description.           

description = description + 'Changed  Product Type  from: ' + oldMap.get(key).Product_Type__c + '\t'+ ' to:  ' +  newmap.get(key).Product_Type__c + '\n' ;
              

 '\n'    new line feed is working

'\t' tab is not working

Any suggestions how I can add tab or space between strings?

 

Ankit AroraAnkit Arora

Unfortunatly string do not understand Tab (\t) so you can only do is :

 

String tabStr = '     ' ;

 

description = description + 'Changed  Product Type  from: ' + oldMap.get(key).Product_Type__c + tabStr+ ' to:  ' +  newmap.get(key).Product_Type__c + '\n' ;

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

sfTrekkersfTrekker

Check with this '\r\t'

 

Thanks,

 

Roshan

Ankit AroraAnkit Arora

Roshan,

 

I think this will introduce a new line between the two words.

Try this in debug logs to know more:

 

String str = 'Ankit\r\tArora' ;
System.debug('str ::::::::: ' + str) ;

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

SFDummySFDummy

I tried both solutions.

 

adding '\r\t' and empty string tabStr = '      ';

 

Neither of them added any space or line between my strings

String tabStr = '     ';
description = 'Changed Product Code ' + '    Old Value:' + '\r\t'+ oldMap.get(key).Rate_Product_Code__c + tabStr +  'New Value: ' +  newmap.get(key).Rate_Product_Code__c + '\n' ;
                

 

Mark Hartnady 23Mark Hartnady 23
Try this:
https://salesforce.stackexchange.com/questions/65381/convert-ascii-code-to-equivalent-character
Mark Hartnady 23Mark Hartnady 23
String myChar = String.fromCharArray( new List<integer> { 9 } );