Populate "Assigned To" field in Evidence table from Control table's Owner field using UI Builder in

JawaharGunt
Giga Contributor

I’m working in the Audit Workspace and want to automatically populate the "Assigned To" field in the Evidence table with the Owner value from the related Control table. This should happen when a user clicks the New button in the Evidence related list.

I plan to implement this using UI Builder, and I’m looking for guidance or best practices on how to:

  • Access the Control table’s Owner field dynamically.
  • Pass that value into the Assigned To field in the Evidence form.
  • Ensure this works seamlessly within the Audit Workspace context.

Has anyone implemented something similar or can share tips on configuring this in UI Builder?

 

JawaharGunt_0-1761716911184.png

 

JawaharGunt_1-1761716910817.png

 

 

4 REPLIES 4

Sarthak Kashyap
Tera Guru

Hi @JawaharGunt ,

 

From screenshot I think assigned_to field is string type of field and it is passing the sys_id, so for that make the field type as reference to sys_user table or if you want to make it as string field then try to pass name.

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

Hi Sarthak ,

Thank you for pointing that out.
You’re correct — if the assigned_to field is currently a string type, passing the sys_id will not work as expected.

  • Actually I am unable to pass the parent record owner into assigned it and  the sys id is dynamically inserted not through binding

 

Hi @JawaharGunt ,

 

Can you please check below link

 

https://www.servicenow.com/community/servicenow-ai-platform-articles/populate-fields-when-clicking-n...

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak

Hi @JawaharGunt ,

 

I tried your problem in my PDI and it is working fine for me please check below code 

 

I created onLoad client script and add below code 

 

function onLoad() {
    // var annotations = getAnnotations();
	alert("123");
    if (g_form.isNewRecord()) {
        // Retrieve the parent incident sys_id from the URL parameter
        var parentIncidentID = g_form.getValue('parent_incident');
		alert("HEre 123 = " + parentIncidentID);

        // Use GlideAjax to get the details of the parent incident
        var ga = new GlideAjax('GetParentIncidentDetails');
        ga.addParam('sysparm_name', 'getParentDetails');
        ga.addParam('sysparm_parent_id', parentIncidentID);
        ga.getXMLAnswer(function(answer) {
            var parentDetails = JSON.parse(answer);

            // Populate the fields on the child incident form
            if (parentDetails.description) {
                g_form.setValue('description', parentDetails.description);
				g_form.setValue('short_description', parentDetails.short_description);
				g_form.setValue('assigned_to', parentDetails.assigned_to);
            }
            // Add more g_form.setValue() lines here for other fields
            // Example: g_form.setValue('short_description', parentDetails.short_description);
        });
    }
}

 

SarthakKashyap_0-1761725149323.png

 

After that I created script include which is AJAX enable and added below code 

var GetParentIncidentDetails = Class.create();
GetParentIncidentDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {

	getParentDetails: function() {
            var parentID = this.getParameter('sysparm_parent_id');
            var parentIncident = new GlideRecord('incident');
            if (parentIncident.get(parentID)) {
                var details = {};
				details.assigned_to = parentIncident.getValue("assigned_to");
                details.description = parentIncident.getValue('description');
                details.short_description = parentIncident.getValue('short_description');
                // Add more fields as needed
                return JSON.stringify(details);
            }
            return '{}';
        },

    type: 'GetParentIncidentDetails'
});

 

SarthakKashyap_1-1761725184191.png

 

Result: 

 

This is parent 

SarthakKashyap_2-1761725256235.png

When created child

SarthakKashyap_3-1761725299681.png

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards,

Sarthak