Need to autopopulate the value in Change Request table based on a reference variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2024 09:54 AM
I have a situation where I need to set a choice field (doesnt have to be a choice, can be free text as well) to yes or no based on which configuration item is chosen. As an example - if someone selects an application that is marked as a SOX Compliant app as the configuration item the change is based upon, I need the "Is SOX?" field to auto-populate to "yes" or "No" based on the value of that field in the actual config item record. please see screenshots.
is this something that I should do in flow designer? or can I do this simply within the change record?
     
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2024 09:15 AM
This is your server side logic, you need a client script to call this code.
var Autopopulate = Class.create();
Autopopulate.prototype = Object.extendsObject(AbstractAjaxProcessor, {
myfunction: function() {
var value = '';
var ci = this.getParameter('sysparm_is_sox');
var grCCWS = new GlideRecord('cmdb_ci_web_server');
if (grCCWS.get(ci)) {
value= grCCWS.field_name;// give your backend field name of sox application specific field.
}
return value;
},
type: 'Autopopulate'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2024 09:52 AM
ok, here's what i've got for the script includes and the client script. does this all look correct?
  
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2024 12:06 PM - edited ‎10-17-2024 12:07 PM
Hi
Your script include name should be 'Autopopulate' as per your script.
Remove line 16,17 from your client script, We are only returning 1 value from the script include. and use answer in your setValue method.
g_form.setValue('field_name',answer); // replace fieldname
Please Mark responses as helpful if this helps you to understand. Accept Solution if this gives you the answer your looking for!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2024 11:48 AM
Hi @cameron8
Is your issue fixed?
Please close this question by marking response as helpfuls and correct answer.