- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 08:25 AM
Good morning SN Community,
I have a requirement to create multiple release validation tasks using a UI action on the task form. The script should allow for multiple requests to be created based on the selection of releases chosen in a field ('u_releases' so if there are 6 releases chosen, then 6 tasks should be created with each mapped to a release.). However, when I go to enact the UI action on the form, nothing happens. Can someone please tell me what I'm doing wrong? Here is my script:
createNewRecords ();
function createNewRecords() {
if (typeof current.number != 'undefined' && current.number)
current.number = ""; //generate a new nunmber
else if (typeof current.u_number != 'undefined' && current.u_number)
current.u_number = ""; //generate a new number
var grParentRecordTable = new GlideRecord('x_namim_edrm_nos_erdm_releases'); //Release Table
grParentRecordTable.addEncodedQuery('sys_idIN' + curent.u_releases.toString()); //List field of child releases
grParentRecordTable.query();
while (grParentRecordTable.next()) {
var grMassTasks = new GlideRecord('x_namim_edrm_nos_patch_schedule_task'); //Validation Task table
grMassTasks.initialize();
grMassTasks.release = grParentRecordTable.sys_id;
grMassTasks.signup = grParentRecordTable.u_mass_signup;
grMassTasks.assignmentGroup = grParentRecordTable.assignment_group;
grMassTasks.validationContact = grParentRecordTable.assigned_to;
grMassTasks.contact = grParentRecordTable.validation_contact_cell_number;
grMassTasks.ciName = grParentRecordTable.cmdb_ci;
grMassTasks.type = grParentRecordTable.validation_type;
grMassTasks.insert();
}
answer = current.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-23-2022 09:56 AM
Hello New Developer,
You can accomplish this by creating an array on the value you are using to create new records with. Also, when you are mapping fields to replicate across records, you will need to write it out as it is on the form as shown here:
grMassTasks.u_mass_signup = current.u_mass_signup;
See my script below for that and let me know if you have any further questions. You should be able to do a copy / paste and test it out in your environment.
(function(current) {
var releases = current.u_releases.toString().split(',');
for (var i = 0; i < releases.length; i++) {
grMassTasks = new GlideRecord('x_namim_edrm_nos_patch_schedule_task');
grMassTasks.initialize();
grMassTasks.parent = current.parent;
grMassTasks.u_mass_signup = current.u_mass_signup;
grMassTasks.assignment_group = current.assignment_group;
grMassTasks.assigned_to = current.assigned_to;
grMassTasks.validation_contact_cell_number = current.validation_contact_cell_number;
grMassTasks.cmdb_ci = current.cmdb_ci;
grMassTasks.validation_type = current.validation_type;
grMassTasks.u_releases = releases[i];
grMassTasks.insert();
}
})(current);
**Please mark my answer Correct or Helpful if applicable so that others may benefit if needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 08:40 AM
My first idea is you run this ui action client side instead of server side.
Second can you tell us if you see any error messages in the logs and / or console?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 08:59 AM
Hi Jorn,
Thank you so much for replying to me. The script is running client side and there are no errors in the logs. I can't do a gs.log in the script because of BPE, but I was watching the logs while testing and there was nothing there.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 08:41 AM
I do not understand this need for
answer = current.insert()
Try without that line.
Also, is your UI Action running on server? ensure the Client checkbox is not checked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2022 09:00 AM
Hello AnirudhKumar,
Thank you so much for your reply. The client checkbox is not enabled and I've removed the last line of code in my script, but still nothing happens when I go to create the duplicate records. Do you see any issues with my code?