Hi Server Side Scripting - Record Producer & Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 08:42 AM
Hi - I have built my first record producer (previously have only done request items) and I'm relatively new to building scripts, both client and server side. Here's the situation I have that I need to solve using scripting on the server side.
My main table for my record producer is called DNRC Personnel Action Form and then there is another task that is called DNRC Personnel Action Form Task. Because I need to be able to show the task table information when our ITIL users are working in specific record producers, I have created a relationship between these two tables - because they otherwise aren't related. Here's what the relationship looks like:
Applies to Table: DNRC Personnel Action Form [x_g_som_dnrc_onb_0_personnel_action_form]
Queries from Table: DNRC PAF Task [x_g_som_dnrc_onb_0_paf_task]
I then was able to go to a submitted record producer and change the form to include the PAF tasks from that table (Tasks Included attachment). However, I know I need to go back to the relationship and narrow the tasks being queried by inserting a script (Query-Script Screen attachment). Because I don't have a lot of scripting experience, I'm totally lost - but I know this is a relatively simple thing and hoping someone in the group can help me write this. A couple other notes - not sure if they matter, but thought I'd include: I need to grab all related tasks, not just open ones. Some of the tasks will also run parallel.
Thanks everyone!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 05:42 PM
I need to retrieve all related tasks - What's the relationship here? Are they considered related because they have been created for the same user?
Why not create a simple Parent Child relation.
Parent - DNRC Personnel Action Form
Child - DNRC Personnel Action Form Task - Assuming you cannot just create a DNRC Personnel Action Form Task, without having a DNRC Personnel Action Form.
This will easily support One to Many relationship.
Please accept solution OR mark helpful.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 08:03 AM
Hi - they are considered related because the task is completed as part of the Personnel Action Form Process. And your assumption is correct - you can't create a DNRC Personnel Action Form Task without having a DNRC Personnel Action Form.
To do what you suggested, I would just create a reference field on the child table (DNRC Personnel Action Form Task) that referenced the parent table (DNRC Personnel Action Form), correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 02:16 PM
Yes exactly, you will need to create a reference field to the parent table.
Once you create this field on the child table which references the parent table, you can navigate to the parent table form, and add the related list there.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0727727
Above is some documentation.
You will need to change this configuration on the dictionary entry of your newly created reference field, in case you want to allow the creation of DNRC tasks from the related list.
Please accept solution OR mark helpful.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 02:24 PM
Another advantage is, if you use this approach, and someone tries to create a new DNRC task, the custom reference field will auto set to the parent DNRC record.
Thanks,