how to script | if (serviceportal) ...| Client Script

Simon Ciglia
Giga Guru

Dear SNC

I want to avoid multiple scripts, thats why I want to code if(serviceportal)...in client script

 

any help is highly appreciated

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi,

Here is an official documentation from SN on how to separate a script for portal and platform execution.

Checking desktop vs mobile runtime

You might want to mark a client script compatible with both desktop and mobile, but include behavior that depends on the runtime. You can use this script:  https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/concept/unsupported_client_scripts.html
  if (window === null)
    // Write your mobile or service portal compatible code here
  else
    // Write your desktop compatible code here


View solution in original post

2 REPLIES 2

Omkar Mone
Mega Sage

Hi 

If(window === null) will return you true if it is on the Native Ui and not portal. It's else {} would indicate that it is Service Portal. 

 

Hope this helps.

 

Regards,

Omkar Mone

Alikutty A
Tera Sage

Hi,

Here is an official documentation from SN on how to separate a script for portal and platform execution.

Checking desktop vs mobile runtime

You might want to mark a client script compatible with both desktop and mobile, but include behavior that depends on the runtime. You can use this script:  https://docs.servicenow.com/bundle/newyork-servicenow-platform/page/build/service-portal/concept/unsupported_client_scripts.html
  if (window === null)
    // Write your mobile or service portal compatible code here
  else
    // Write your desktop compatible code here