Populate "Assigned To" field in Evidence table from Control table's Owner field using UI Builder in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @JawaharGunt ,
Can you please check below link
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
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);
});
}
}
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'
});
Result:
This is parent
When created child
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak
