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
Adil_SFDCAdil_SFDC 

Displaying PICK LIST Values in a single line

Hi All 

 

I need to send a request to another URL

This is my request 

endpoint = 'http://api.icentera.com/v1/TestService.svc/json/SearchDocumentsForSF?token='+tokenval+'&search=&sfValues=Industry__c:'+o.Industry__c+'&page=1';

 

Industry__c is a pick list field which will return values like "Public Safety"

But it should go as "Public+Safety" in the above URL.

How can we make my picklist field value incorporate "+sign" in the space.?

 

Thanks in advance

Jia HuJia Hu
You can keep the Picklist value in a String and replace the space in the vale with anything you want,
then put this revised value in your endpoint link to send.
Abhishek_NewAbhishek_New

u can convert a picklist to text by TEXT(Industry__c) function..try it out..

Rahul SharmaRahul Sharma

Hello Adil_SFDC,

 

Its always better to use url encoding while generating a dynamic URL.

Try using EncodingUtil.urlEncode or some other encoding function.

Adil_SFDCAdil_SFDC

This solved my problem

 

String pickval = String.valueof(o.Industry__c);

if(pickval!=null)

pickval=pickval.replace('  ','+');

system.debug('--------'+pickval);

 endpoint = 'http://api.icentera.com/v1/TestService.svc/json/SearchDocumentsForSF?token='+tokenval+'&search=&sfValues=Industry__c:'+pickval+'&page=1';

Adil_SFDCAdil_SFDC

I would like to solve this usung urlencode. Any suggestions

Rahul SharmaRahul Sharma

When encoding a String, the following rules apply :


1. The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same
2. The special characters ".", "-", "*", and "_" remain the same.
3. The space character " " is converted into a plus sign "+".
4. All other characters are unsafe and are first converted into one or more bytes using some encoding scheme.
Then each byte is represented by the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the byte.
5. The recommended encoding scheme to use is UTF-8.
However, for compatibility reasons, if an encoding is not specified, then the default encoding of the platform is used.

Adil_SFDCAdil_SFDC

Hi 

 

Can you suggest me an example on how to use encoding.url based on the Url in my question please