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

Amol Pawar
Tera Guru

Hi @Ankur Bawiskar,

 

Any solution on this thread?

 

Thanks in advance,

Amol

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