- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2022 06:51 PM
I am new to ServiceNow. I have created a field u_inc_reason on the incident form, and also created a field u_prb_reason on the problem form. I want the value from the incident (u_inc_reason) to be copied to the problem record when the create proble ui action is used on the incident form. I have tried writing a business rule and also tried updating the create problem ui action but have not been successful. Any script available to achieve that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2022 02:17 AM
Hi @Bintes
Please find the updated script of 'Create Problem' UI Action:
var prob = new IncidentUtils().getProblemFromIncident(current);
if (prob != undefined) {
current.problem_id = prob.insert();
if (current.state != IncidentState.RESOLVED) {
current.state = IncidentState.ON_HOLD;
if (current.isValidField("hold_reason"))
current.hold_reason = IncidentState.AWAITING_PROBLEM;
}
if (GlidePluginManager.isActive("com.snc.best_practice.problem.madrid")) {
var problemV2Util = new ProblemV2Util();
problemV2Util.copyAttachments(current, prob);
problemV2Util.copyAttachedKnowledge(current, prob);
}
current.update();
gs.addInfoMessage(gs.getMessage("Problem {0} created", prob.number));
action.setRedirectURL(prob);
action.setReturnURL(current);
var prb = new GlideRecord('problem');
prb.addQuery('sys_id',prob.sys_id);
prb.query();
if(prb.next())
{
prb.u_prb_reason = current.u_inc_reason;
prb.update();
}
} else {
action.setRedirectURL(current);
}
Added some script in Line 20 to 27.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2022 12:44 AM
Hi @Bintes,
I hope you have gone through the Create Problem UI action on incident table. You have to just add the below line to update your INC field to PRB field.
prob.u_prb_reason = current.u_inc_reason;
current.problem_id = prob.insert(); // OOTB scritps line
Thanks,
Sagar Pagar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2022 01:00 AM
Hi,
This is doable, but only if the two custom fields you've created can contain the same values, and they are of the same data type (String, Integer, Reference and so on)
You should be able to modify the OOB UI action that copies the incident record data to a new problem record.
Try adding a line that looks something like below:
problemGR.u_prb_reason = current.u_inc_reason;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2022 02:17 AM
Hi @Bintes
Please find the updated script of 'Create Problem' UI Action:
var prob = new IncidentUtils().getProblemFromIncident(current);
if (prob != undefined) {
current.problem_id = prob.insert();
if (current.state != IncidentState.RESOLVED) {
current.state = IncidentState.ON_HOLD;
if (current.isValidField("hold_reason"))
current.hold_reason = IncidentState.AWAITING_PROBLEM;
}
if (GlidePluginManager.isActive("com.snc.best_practice.problem.madrid")) {
var problemV2Util = new ProblemV2Util();
problemV2Util.copyAttachments(current, prob);
problemV2Util.copyAttachedKnowledge(current, prob);
}
current.update();
gs.addInfoMessage(gs.getMessage("Problem {0} created", prob.number));
action.setRedirectURL(prob);
action.setReturnURL(current);
var prb = new GlideRecord('problem');
prb.addQuery('sys_id',prob.sys_id);
prb.query();
if(prb.next())
{
prb.u_prb_reason = current.u_inc_reason;
prb.update();
}
} else {
action.setRedirectURL(current);
}
Added some script in Line 20 to 27.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023