populate field with manual value push from script based on condition met on other catalog form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 03:11 AM
i have to catalog one is customer on boarding other env on boarding .
customer onboarding have field a,b,c yes/no we cane give based on that their is field on env onboarding has to populate with value given in script .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 03:35 AM - edited 02-28-2025 03:37 AM
You can make a use of catalog client script + script include.
imaginary ccs:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) return;
// Get the current values of fields a, b, and c
var fieldA = g_form.getValue('a'); // Assuming 'a', 'b', 'c' are the field names
var fieldB = g_form.getValue('b');
var fieldC = g_form.getValue('c');
var environmentFieldValue = '';
if (fieldA == 'Yes' && fieldB == 'Yes' && fieldC == 'Yes') {
environmentFieldValue = 'Option 1'; // Populate with a specific value if all are Yes
} else if (fieldA == 'Yes' && fieldB == 'No' && fieldC == 'Yes') {
environmentFieldValue = 'Option 2';
} else if (fieldA == 'No' && fieldB == 'Yes' && fieldC == 'No') {
environmentFieldValue = 'Option 3';
} else {
environmentFieldValue = 'Default';
}
var ga = new GlideAjax('UpdateEnvironmentOnboarding');
ga.addParam('sys_id', g_form.getUniqueValue());
ga.addParam('environmentField', environmentFieldValue);
ga.getXMLAnswer(function(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
});
}
Script include
var UpdateEnvironmentOnboarding = Class.create();
UpdateEnvironmentOnboarding.prototype = Object.extendsObject(AbstractAjaxProcessor, {
updateEnvironmentField: function() {
var customerOnboardingSysId = this.getParameter('sys_id');
var environmentFieldValue = this.getParameter('environmentField');
var gr = new GlideRecord('sc_req_item');
if (gr.get(customerOnboardingSysId)) {
gr.environment_field = environmentFieldValue;
gr.update();
}
return 'Success';
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 03:39 AM
if any one from a or b or c is yes then we have to push value LIQ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 04:18 AM
@amitesh2 You can Add || (OR) condition according your requirement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2025 03:37 AM
so what's your form and how it looks and what did you start with and where are you stuck?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader