- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 01:13 AM
I am unable to track assets assigned to the user. While sumitting termination form for the user all the hardware assigned to that user should be tagged in one task. I am only able to tag one hardware using workflow catalog task condition.
The code I added is
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 01:41 AM - edited 07-17-2024 01:52 AM
Hi @divyal09,
(Updated - I forgot to un-comment the task.description during my testing)
Use the below slightly updated script.
You needed to append to the hardware_details each for each loop and only update the task.description after this. See below:
var usrid = current.variables.employee_name;
var hardware = new GlideRecord('alm_hardware');
hardware.addQuery("assigned_to",usrid);
hardware.query();
var hardware_details = '';
while (hardware.next()){
hardware_details += 'Name' + '-' + hardware.display_name + '\n'; // += appends for each asset within the while loop
}
if(hardware_details){ //We only print out or update the task description once the while loop has finished
task.description = 'Please disable/remove access for ' + current.variables.employee_name.getDisplayValue() + ' terminated on ' + dt + ' from your application and where applicable, associated servers, databases and other applications for which user has access.' + '-' + ' '+ hardware_details;
}
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 01:41 AM - edited 07-17-2024 01:52 AM
Hi @divyal09,
(Updated - I forgot to un-comment the task.description during my testing)
Use the below slightly updated script.
You needed to append to the hardware_details each for each loop and only update the task.description after this. See below:
var usrid = current.variables.employee_name;
var hardware = new GlideRecord('alm_hardware');
hardware.addQuery("assigned_to",usrid);
hardware.query();
var hardware_details = '';
while (hardware.next()){
hardware_details += 'Name' + '-' + hardware.display_name + '\n'; // += appends for each asset within the while loop
}
if(hardware_details){ //We only print out or update the task description once the while loop has finished
task.description = 'Please disable/remove access for ' + current.variables.employee_name.getDisplayValue() + ' terminated on ' + dt + ' from your application and where applicable, associated servers, databases and other applications for which user has access.' + '-' + ' '+ hardware_details;
}
To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Kudos.
Thanks, Robbie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 01:49 AM
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2024 01:53 AM