Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Single Line Text variable removing special characters in a record producer

Amol Pawar
Tera Guru

Hi All,

I have created a record producer where I have used a single-line text variable. I'm auto-populating that variable with a value from another table's field. But if I use any special character in that table's field and I try to auto-populate that field's value in the record producer's single-line text variable, it removes the special character and whatever text is in front of that special character.

AmolPawar_0-1699246638959.png

How can I make that variable should allow special characters as well?

 

Thanks in advance,

Amol

1 ACCEPTED SOLUTION

Amol Pawar
Tera Guru

Hi @Ankur Bawiskar,

Thank you for your reply. I got a solution for this:

 

var name = current.getValue("intellectual_asset_name");
var sysID = current.sys_id.toString();
var iaowner = current.getValue("ia_owner");
var unit = current.unit;
var company = current.getValue("the_ip_asset_is_owned_by");
var ipid = current.ip_id;

var encodedName = encodeURIComponent(name);
var encodedSysID = encodeURIComponent(sysID);
var encodedIaowner = encodeURIComponent(iaowner);
var encodedUnit = encodeURIComponent(unit);
var encodedCompany = encodeURIComponent(company);
var encodedIpid = encodeURIComponent(ipid);

var link2 = "/ip?id=sc_cat_item&sys_id=1234567890&sysparm_rec_name=" + encodedName + "&sysparm_rec_sysID=" + encodedSysID + "&sysparm_ia_owner=" + encodedIaowner + "&sysparm_unit=" + encodedUnit + "&sysparm_brand_owner=" + encodedCompany + "&sysparm_ip_id=" + encodedIpid;

gs.getUser().savePreference("sfRedirectPortal", link2);
 
If we use encodedURI component then it is allowing auto populating with special characters as well.
Thank you,
Amol

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Amol Pawar 

how is the auto-population working or configured currently?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Amol Pawar
Tera Guru

Hi @Ankur Bawiskar,

I have created a UI action in one table when clicked, it will navigate us to the record producer with the auto-population of some fields. In the table form, I can use special characters but after auto-population it's not allowing special characters.

Thank you,

Amol

@Amol Pawar 

how are you forming the URL? you must be adding the value in url parameters?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar,

Below is the script from the UI action:

var name = current.intellectual_asset_name.getDisplayValue(); //; current.getValue('intellectual_asset_name')
//gs.addInfoMessage('name='+name);
var sysID = current.sys_id; //g_form.getUniqueValue();
var iaowner = current.ia_owner; //g_form.getValue('ia_owner');
var unit = current.unit;
var company = current.the_ip_asset_is_owned_by;
var ipid = current.ip_id;
var link2 = "/ip?id=sc_cat_item&sys_id=a3907120c3b87d102f7798bc7a013134&sysparm_rec_name=" + name + "&sysparm_rec_sysID=" + sysID + "&sysparm_ia_owner=" + iaowner + "&sysparm_unit=" + unit + "&sysparm_brand_owner=" + company + "&sysparm_ip_id=" + ipid;
gs.getUser().savePreference("sfRedirectPortal", link2);
 
Thanks,
Amol