- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2020 11:07 PM
My requirement is....
parent form---wm_task
child form--time_worked
if i create new child form it will autopopulate parent number....i want to autopopulate current logged in user in the "user" field only if that user is part of assigned to or additional assignee list in the parent form..
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 11:21 AM
Hello Pravallika,
Below please find the updated code. Replace your CS and Script Include with below code.
CS:
function onLoad() {
var taskid = g_form.getValue('task');
var ga = new GlideAjax('BBOX_Mapping_Assignedto');
ga.addParam('sysparm_name', 'AssignedtoMapping');
ga.addParam('sysparm_task', taskid);
ga.getXML(HelloWorldParse);
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer == 'true')
g_form.setValue('user', g_user.userID);
}
}
Script Include:
var BBOX_Mapping_Assignedto = Class.create();
BBOX_Mapping_Assignedto.prototype = Object.extendsObject(AbstractAjaxProcessor, {
AssignedtoMapping: function() {
var wotsysid = this.getParameter('sysparm_task');
var wot = new GlideRecord("task");
wot.addQuery('sys_id', wotsysid);
wot.query();
if (wot.next()) {
var assignedTo = wot.assigned_to;
var list = wot.additional_assignee_list.toString().split(',');
list.push(assignedTo.toString());
var arrayUtil = new ArrayUtil();
return arrayUtil.contains(list, gs.getUserID());
}
},
type: 'BBOX_Mapping_Assignedto'
});
Let me know if that answered your question. If so, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
- Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 09:41 PM
Thank you for your reply,
i have acheived it...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 09:56 PM
Hi,
Did you accidentally marked your own comment as correct answer?
The question was already answered I believe using display business rule + onload client script approach.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 10:17 PM
You are very welcome..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 08:31 PM
Hi,
please check updated code
Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
var taskid = g_form.getValue('task');
var ga = new GlideAjax('BBOX_Mapping_Assignedto');
ga.addParam('sysparm_name','AssignedtoMapping');
ga.addParam('sysparm_task',g_form.getValue('task'));
ga.getXMLAnswer(callBack);
function callBack(answer)
{
if(answer.toString() == 'true')
g_form.setValue('user', g_user.userID);
}
}
Script Include:
var BBOX_Mapping_Assignedto = Class.create();
BBOX_Mapping_Assignedto.prototype = Object.extendsObject(AbstractAjaxProcessor, {
AssignedtoMapping: function() {
var wotsysid = this.getParamater('sysparm_task');
var wot = new GlideRecord("task");
wot.addQuery('sys_id', wotsysid);
wot.query();
if (wot.next()) {
var assignedTo = wot.assigned_to;
var list = wot.additional_assignee_list.toString().split(',');
list.push(assignedTo.toString());
var arrayUtil = new ArrayUtil();
var contains = arrayUtil.contains(list, gs.getUserID());
return contains;
}
},
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 09:03 PM
Repeat..