Client Script in MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 07:27 AM
Hi all,
I have a catalog item request with few variables like 'security zone' and 'data center'. Then I have also a MRVS that has a variable 'the_mountpoint', and I want this variable to be populated with values from those 2 fields, however it seems g_form.getValue() is not working... Any solutions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 09:22 AM
In your Catalog Client Script that applies to the MRVS you can use
g_service_catalog.parent.getValue('variable_name');
in place of g_form.getValue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 12:35 AM
Hi Brad,
This indeed helped. I can populated the field with the values however one is getting me the sysID as the value comes from a reference table.
What can I do to get the display value? I tried getDisplayValue() method but seems not to work:
function onLoad() {
// Add logging to check if the onLoad function is triggered
console.log("onLoad triggered");
// Initially populate the_mountpoint_of_the_filesystem on load
updateMountPoint();
// Add listeners for variable changes, if needed
g_form.listenForValueChange('environment', updateMountPoint);
g_form.listenForValueChange('business_app_name', updateMountPoint);
}
function updateMountPoint() {
// Add logging to check if updateMountPoint is called
console.log("updateMountPoint called");
// Use g_service_catalog.parent to retrieve the variables from the parent form
var environment = g_service_catalog.parent.getValue('environment');
var businessAppName = g_service_catalog.parent.getValue('business_app_name');
// Log the values for debugging
console.log("Environment: ", environment);
console.log("Business App Name: ", businessAppName);
// Check if both fields have values
if (environment && businessAppName) {
var mountPoint = environment + " / " + businessAppName;
g_form.setValue('the_mountpoint_of_the_filesystem', mountPoint);
console.log("Mount Point set to: ", mountPoint);
} else {
// If either field is empty, set the mountpoint to an empty string
g_form.setValue('the_mountpoint_of_the_filesystem', '');
console.log("Mount Point set to empty");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2024 03:35 AM
The easiest thing to add to the script is a GlideRecord on the reference table. Use the value retrieved from the parent as the sys_id / record to retrieve, then use the Name field or whatever from that record to populate the MRVS variable.