Script Includes with UI Policies and Client Scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2016 02:14 PM
I have a form with multiple UI Policies running scripts and also some onChange Client Scripts that all basically run the same script.
What I'd like to do is be able to store a single script somewhere and then call that from my UI Policies and Client Scripts. This way, if I need to make changes, I only need to do it in one place.
I've looked at Script Includes but from what I understand, that's server-side; while UI Policies and Client Scripts run Client-Side.
Is there anyway to accomplish this?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2016 11:57 AM
So, I have a couple other questions.
1.
I tried creating on "onLoad" Client Script and setting up a function definition there - 'setUpBillingTab()'.
Basically, this is supposed to set field visibility and mandatory statuses using 'g_form.setDisplay()' and 'g_form.setMandatory()' functions based on 'g_form.getValue()'.
I then have a UI Policy 'Billing Fields - Form Type Selected' and have it set to "Run Scripts" which calls 'setUpBillingTab()' in the onCondition() function. However, when I trigger the UI Policy on my form, I get this error:
onChange script error: ReferenceError: setUpBillingTab is not defined function (){var o=i(m,arguments);return l.apply(n,o)}
Both the Client Script and the UI Policy apply to the same table. I've tried placing the 'setUpBillingTab()' function both inside and outside the 'onLoad()' function of the Client Script but get that error either way.
2.
I read the articles about GlideAjax and UI Scripts, but I'm wondering if there's a preferred best practice.
With GlideAjax, will that only pull values that are stored in the database or will it read field values the user has changed before saving the form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2016 06:38 AM
Could you please share the scripts of on load and on change client scripts? Then I will be able to debug exactly your use case - for me it was working when I set on load client script with function definition outside of on load function and then called it in on change client script or UI policy.