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.

Hide variable only in Service Portal

Geeky
Kilo Guru

Hi All,

How can I hide a variable only in Service Portal? The variable must be visible in native self service catalog.

1 ACCEPTED SOLUTION

Utpal Dutta1
Mega Guru

Hey Geeky,

You can use a UI policy or Client script to hide the variable, and make sure the Run scripts in UI type field is set to Mobile/Service Portal. In that case it will only run on service portal and not in the standard catalog view.

 

It's the most simple way to achieve the solution you want. If my answer helps then please mark it Correct and Helpful.

 

Thanks and Regards:

Utpal Dutta

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can have onload catalog client script for this and check whether it is SP page

function onLoad(){

var url = top.location.href;

if(url.indexOf('/sp') > -1){

// this is sp page and hide the variable

g_form.setDisplay('variableName', false);

}

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Thank you, This works better than other pointless explanations.

Utpal Dutta1
Mega Guru

Hey Geeky,

You can use a UI policy or Client script to hide the variable, and make sure the Run scripts in UI type field is set to Mobile/Service Portal. In that case it will only run on service portal and not in the standard catalog view.

 

It's the most simple way to achieve the solution you want. If my answer helps then please mark it Correct and Helpful.

 

Thanks and Regards:

Utpal Dutta

Subhojit Das
Kilo Guru

Hi,

You can write a Client script on the catalog item to hide the variables in Service Portal. You will find a choice list field called "UI Type" where you have to choose Mobile/Service Portal option.

find_real_file.png

You can also use Catalog UI Policy:

find_real_file.png

 

 

You can also refer the below link for better understanding:

https://community.servicenow.com/community?id=community_question&sys_id=6f9cec38db3d2f009540e15b8a96...

https://community.servicenow.com/community?id=community_question&sys_id=855e6145db7be7801cd8a345ca96...

https://docs.servicenow.com/bundle/orlando-application-development/page/script/client-scripts/concep...

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

Regards,

Subhojit Das