- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 12:51 AM - edited 03-06-2023 12:54 AM
I need to create tasks on basis of a comma separated field values.
I have a field in parent table of type "string" having input as 123,456,789.....Now i need to create task in the child table with these input in the short description of the task
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 11:55 PM
then update the field on child which holds parent
var vastIds = current.parent_record.u_type_of_work.toString().split(',');
for(var i=0; i<vastIds.length; i++)
{
var newTask = new GlideRecord('child_table');
newTask.initialize();
newTask.u_task_type = "xyz";
newTask.u_parentField = current.sys_id;
newTask.insert();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 01:03 AM
when you want child records to be created?
you can have after insert/update BR on parent and have the logic defined.
what did you start with and where are you stuck?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 02:09 AM
I am trying to take values from a field on parent record ie.u_type_of_work
var vastIds = ((current.parent_record.u_type_of_work).toString()).split(',');
{
for(i=0;i<vastIds.length;i++)
{
var newTask = new GlideRecord('child_table');
newTask.initialize();
newTask.u_task_type = "xyz";
newTask.insert();
}
}
I created an after insert BR and not able to create the new task records with above code..Kindly help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 02:25 AM
try this
var vastIds = current.parent_record.u_type_of_work.toString().split(',');
for(var i=0; i<vastIds.length; i++)
{
var newTask = new GlideRecord('child_table');
newTask.initialize();
newTask.u_task_type = "xyz";
newTask.insert();
}
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 01:08 AM
Then you can store that number in any variable and while creating a new task just add the value of that variable into short_description.
Mark as correct if it will helpful.