- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 11:45 AM
I have a catalog form with label named "assigned_asset" when the submitter select an asset id in the catalog item, I need to have an OnChange script for the "assigned_asset" and pull the location from the asset table. I need to have a script asynchronous so that it does not impact the user experience and it is "best practice". I have the script below but not able to get anything back. Any help appreciated. Or should I try to do a Glide Ajax to pull the information? Please advise or let me know what need to do to fix the script my experience scripting is very limited. Thank you for advise or guidance.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
try {
g_form.getReference('asset', callback); /* asset table */
function callback(ret) {
g_form.setValue('location', ret.location);
}
} catch (ex) {
g_form.addErrorMessage(" TYPE [on Asset Change] encountered the error: " + ex.message);
g_form.addInfoMessage("TYPE [on Asset Change] encountered the error:" + ex.message);
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:08 PM
As far as I know, getReference() only works with reference fields/variables, so it will not work with Lookup SelectBox. I would recommend you to use GlideAjax for this requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:08 PM
As far as I know, getReference() only works with reference fields/variables, so it will not work with Lookup SelectBox. I would recommend you to use GlideAjax for this requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:13 PM
Ok. If I change the variable to a Reference then when display the catalog item I am able to select the field but does not bring them back to the screen.
Khan, thank you for your patience and guidance.
Luis
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:17 PM
Sorry I didn't get what you mean by "Does not bring them back to the screen."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:27 PM
THat's correct. Sorry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:39 PM
Glad it helped.