Record producer works fine in portal but not as expected in native UI

sathwikc
Tera Contributor

Hi community, I have created a record producer where it has several fields and works perfectly when submitted from the portal, but when I tried submitting from native UI some fields are not getting cleared as expected.

There is field 'A' which is a select box of 3 options.
field 'B' which is a Y/N.

field 'C&D' which are select box, 'C' has 3 options and 'D' has 2 options.

I have script were based on user selection the values get populated. For example, in field 'A' if I select 2nd option and 'B' as 'yes', then 'C&D' gets populated. Similarly, if selected 'no', value gets cleared when submitted in portal; as per written in my onsubmit script.

But if I tried same scenario from native UI (Try It), when user selects 'B' as 'no', the values show up ('C&D' should get cleared up). It should get cleared as worked in portal. Is there anything like applies to catalog item, applies to request item same as catalog item for record producer? I have kept UI type as all and targeted record as true.

These fields are mapped on Short Description on Incident form.

1 ACCEPTED SOLUTION

fknell
Tera Patron

Hi @sathwikc,

This is a classic Record Producer scripting difference between Service Portal and Native UI. Your onsubmit script is working in the portal but not clearing fields in Native UI because of script context and execution differences.

 

Native UI and Service Portal have different script execution contexts:

Native UIService Portal
Synchronous client scriptsAsynchronous client scripts
g_form behaves differentlyg_form + Angular context
Form submission happens fasterForm waits for script

 

You have to tackle the situation by using a combination of onChange and onSubmit.

 

Hope this helps!

View solution in original post

4 REPLIES 4

fknell
Tera Patron

Hi @sathwikc,

This is a classic Record Producer scripting difference between Service Portal and Native UI. Your onsubmit script is working in the portal but not clearing fields in Native UI because of script context and execution differences.

 

Native UI and Service Portal have different script execution contexts:

Native UIService Portal
Synchronous client scriptsAsynchronous client scripts
g_form behaves differentlyg_form + Angular context
Form submission happens fasterForm waits for script

 

You have to tackle the situation by using a combination of onChange and onSubmit.

 

Hope this helps!

sathwikc
Tera Contributor

So do I need to create scripts again for native UI, as I do have for onChange and onSubmit?
I have been testing it out like making inactive and active back the scripts. Works perfectly in portal, but not on native UI

Ankur Bawiskar
Tera Patron

@sathwikc 

did you debug the client script if alert came for native?

what debugging did you do?

share your script and config screenshot for client script

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

Sorry that I can't share you the script, but after thorough testing, I got to know that there are some conflicts within my scripts and UI policies