ClientScript - onSubmit() I want to get the value of a reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 01:38 AM
Hi,
I am thinking of an onSubmit catalog client script that gets another value for that field from a variable of type reference.
I tried the following script, but could not do it.
Please let me know the solution.
//"variables_name" contains variables of the catalog item's reference type.
var result = g_form.getReference(variables_name, function(user) {
g_form.getValue(user.user_name);
});
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 02:53 AM
The requirements were indeed unclear.
It is to get another value (user_name) for the field from a variable of the catalog item's reference type in onSubmit and store it in a variable (result) for use as a subsequent process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 03:02 AM
if the ask is to auto-populate another variable based on 1st variable then you should use onChange client script and not onSubmit
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 03:05 AM
Sorry. The wording was misleading.
The variable (result) here is not a catalog item variable.
It is a variable created temporarily for use within the catalog client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 03:16 AM
so what is the result ?
Very difficult to understand without the screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 03:38 AM
"result" is a variable created in the script as follows.
In this case, I named it "result," but it can be anything.
This may not be a good example, but this is the image you want to use in subsequent processing, such as displaying this value in an error message.