Need to autopopulate the value in Change Request table based on a reference variable

cameron8
Tera Contributor

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?

Screen Shot 2024-10-15 at 11.54.22 AM.png

Screen Shot 2024-10-15 at 11.53.06 AM.png

Screen Shot 2024-10-15 at 11.52.28 AM.png

Screen Shot 2024-10-15 at 11.51.57 AM.png

Screen Shot 2024-10-15 at 11.51.50 AM.png

     

8 REPLIES 8

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 it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

ok, here's what i've got for the script includes and the client script. does this all look correct?

 

Screenshot 2024-10-17 at 11.51.56 AM.png

Screenshot 2024-10-17 at 11.50.23 AM.png

  

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 it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hi @cameron8 

Is your issue fixed?

Please close this question by marking response as helpfuls and correct answer.

 

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP