Copy the CI from a problem record into a problem task related to it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 05:55 AM
I have a related list table (problem_task) related to the problem table, which allows me to create new problem tasks related to a problem record.
Looking for a quick way to copy the CI from the problem into the newly created problem tasks. (as I want this to happen when I use the NEW button in the related list).
Any quick tips on that?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 06:06 AM
Hi Dimitar,
To do this, you need a display business rule and an onLoad client script. Pretty simple stuff.
Display business rule:
Table: Problem task
Insert: true
Update: false
Advanced: false
Condition: Blank
Script:
g_scratchpad.ci_id = current.problem;
g_scratchpad.ci_display = current.problem.getDisplayValue();
Client script:
Table: problem task
Type: onLoad
Script:
function onLoad() {
g_form.setValue('cmdb_ci', g_scratchpad.ci_id, g_scratchpad.ci_display);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-01-2016 12:00 AM
This is exactly what did the trick for me. Only one remark, the way you have it written above brings the ID of the problem record in the field, the correct lines are:
g_scratchpad.ci_id = current.problem.cmdb_ci;
g_scratchpad.ci_display = current.problem.cmdb_ci.getDisplayValue();
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 06:29 AM
Hi Dimitar,
Write Display business rule to copy problem CI to Problem task CI.
Refer below details to create business rule:
Table:Problem Task(problem_task)
When to run: display
Condition: Problem is not Empty
Script:
var prob = new GlideRecord('problem');
prob.addQuery('sys_id',current.problem);
prob.query();
if(prob.next())
{
current.cmdb_ci = prob.cmdb_ci;
}
Regards,
Swapnil
PS: Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 06:41 AM
why not just customize the form.. and add the parent.ci to the form as a read only field?
the only time this would be bad is if you had a need for the ci on the task to be different from it's parent record.. but it sounds like that isn't the norm for you...