Create a Demand from a record producer that also creates a child Demand Task upon submission
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 12:58 PM
I have a demand record producer. The ask is that along with the demand being created, that a child demand task also gets created. I was able to do this through Incident, but not through demand. I'm using the following script:
var gr = new GlideRecord('dmn_demand_task');
gr.initialize();
gr.dmn_demand = current.sys_id;
//gr.insert();
gr.short_description = "This is just a test";
gr.assignment_group = 'aaccc971c0a8001500fe1ff4302de101';
var task2ID = gr.insert();
When I try it without the above script, it creates a demand as expected. If I add the above script, I get this error:
Then it DOES create a demand task, but does NOT create a demand. So the DTASK shows up with no parent. Very strange. Any thoughts? Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2022 01:34 PM
Hi, as you have only posted part of your code the forums ability to identify your issue is limited.
Perhaps you could update this thread with clear and specific details of your configuration, including all of the code for your record producer script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 04:44 AM
Hey Tony. Thanks for the reply. That's actually the full code. I did have some fields mapped within the code but have since removed it to isolate just the part I'd like to create the Demand Task.
So if you were you paste this code into another demand record producer as is (and just change the sys_id to an assignment group in your instance), it should perform as I described above. It creates the DTask, but somehow prevents the actual demand from being created. If you remove the code, the demand creates normally, but then no dtask. Hope that helps. Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2022 09:41 AM
Update: Making progress. Using the following code:
// //Create DTASK that is a child of the Demand
var gr = new GlideRecord('dmn_demand_task');
gr.initialize();
gr.parent = current.sys_id;
gr.short_description = "This is just a test";
gr.assignment_group = 'aaccc971c0a8001500fe1ff4302de101';
gr.parent = current.sys_id;
var task2ID = gr.insert();
There is an OOB business rule called "Prevent DemandTask Hierarchy" which I had to disable.
It now created the Demand with a DTask underneath it. However, I now get this error:
"Error Message