- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 12:15 AM
Hi guys,
After reading a couple of days Docs and this forum, I still didn't find the answer.
(link to Docs: Scripted templates)
I'm running a workflow from RITM and creating a Change ticket with a couple of change tasks. I'm using a template to create all these -- success.
However, the template is not adding the affected CI to the change ticket and I also cannot add it by passing the values from the workflow. If I don't apply the template, the values are passed successfully but together with template it seems that it's not possible. Can someone suggest a workaround?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2018 12:28 AM
Finally got this working. I created an event that I launch from Change Request workflow as a final task. RITM workflow then waits for this event and continues after it's launched.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 12:59 AM
Can you please share the screenshots of the template and the Workflow where you are using this template ...
How are you using a template to get the dynamic CI populated ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 01:47 AM
I'm not using the template to get the CI populated. The workflow was supposed to do it.
In the workflow activity, I'm using the following code:
var change = new GlideRecord('change_request');
change.initialize();
change.applyTemplate('TEMPLATE_NAME');
change.cmdb_ci = current.configuration_item; //not working with template
change.parent = current.number; //not working with template
current.comments = 'Change ticket ' + change.number + ' created. Setting Status to Pending.';
current.state = -5; //set State to "Pending"
activity.result = change.number;
So, in this case the Change request is created using the template but the problem is that the affected CI is not updating. However, if I comment out the row "change.applytemplate", affected CI is added to the Change request. It seems to me that they are not working at the same time and I'm trying to find a workaround for this. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 02:18 AM
no insert or update ... hmm interesting
can you try this ...
var change = new GlideRecord('change_request');
change.initialize();
change.cmdb_ci = current.configuration_item;
change.parent = current.number;
change.applyTemplate('TEMPLATE_NAME');
current.chnageRequest = change.insert();
current.comments = 'Change ticket ' + change.number + ' created. Setting Status to Pending.';
current.state = -5; //set State to "Pending"
activity.result = change.number;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2018 02:41 AM
Thanks for the proposal. I tried applying those in different order too, not working. Applying the template seems to clear all other values.
I now managed to pass the created Change ticket number to the next activity using scratchpad and I'm updating the Affected CI and Parent in the next activity. However, the tasks created within the template do not have the affected CI in this case so the solution still isn't perfect.
edit: I don't understand the row:
current.changeRequest = change.insert();
In the current record (Requested item) there is no field ChangeRequest.
edit2: I also tried adding "change.inser();" but it only caused Change ticket to be created twice.
I also ran into new problems. Even if the Change template creates the tasks correctly (even without affected CI), the tasks are not related to the Change state --> Tasks can be done even if the Change is not in State "Implement" yet. Perhaps I need to create the tasks also using workflow.