- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2023 07:14 AM - edited ‎08-16-2023 07:44 AM
Hi Team,
am writing the below before BR in incident table for creating a problem record for inc which moves to resolved state, am able to get the problem record creation, but first reported by(field inside problem record) and problem id( field inside inc record) is not getting mapped. The same code is working in my PDI, but not in my dev instance.(highlighted code in red is not working in dev instance but working in my pdi)
Can someone please suggest the modifications that is required
var prbGR = new GlideRecord("problem");
prbGR.initialize();
prbGR.description = current.description;
prbGR.short_description = current.short_description;
prbGR.cmdb_ci = current.cmdb_ci;
prbGR.impact = current.impact;
prbGR.urgency = current.urgency;
prbGR.priority = current.priority;
prbGR.company = current.company;
prbGR.business_service = current.business_service;
prbGR.service_offering = current.service_offering;
prbGR.sys_domain = current.sys_domain;
prbGR.first_reported_by_task = current.getUniqueValue();
prbGR.insert();
current.problem_id = prbGR.sys_id;
gs.addInfoMessage(gs.getMessage("Problem {0} created", prbGR.number));
action.setRedirectURL("incident.do?sys_id=" + current.sys_id.toString());
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 01:13 AM
Thank you so much for investing time on this. I found the issue. It was with setting the display value to true for a different field in the problem table instead of number field. Once the change is made to the table level columns the issue got resolved.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2023 07:17 AM
Hi @roshini1
What is current here? like are you running this BR but on which table?
first_reported_by_task is this a field referencing to task table?
Is this BR runs after or before update?
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2023 07:19 AM
What is current here? like are you running this BR but on which table?
the bR is running in incident table, so current in incident table fields
first_reported_by_task is this a field referencing to task table?
it's in problem record
Is this BR runs after or before update?
it's a before BR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2023 07:51 AM
ok new questions.
I know 'first_reported_by_task' is from problem but is it referencing to task table ?
if Yes, the try using following instead of 'prbGR.first_reported_by_task = current.getUniqueValue();':
prbGR.first_reported_by_task = current.sys_id;
This BR runs before, then insert or update ?
this should not before insert as you are tying to access the sys_id which may not be created before inserting. so, have it after insert/update .
and test it again with following final script in after insert BR
var prbGR = new GlideRecord("problem");
prbGR.initialize();
prbGR.description = current.description;
prbGR.short_description = current.short_description;
prbGR.cmdb_ci = current.cmdb_ci;
prbGR.impact = current.impact;
prbGR.urgency = current.urgency;
prbGR.priority = current.priority;
prbGR.company = current.company;
prbGR.business_service = current.business_service;
prbGR.service_offering = current.service_offering;
prbGR.sys_domain = current.sys_domain;
prbGR.first_reported_by_task = current.sys_id; // this field 'first_reported_by_task' should be referencing to incident/task
var newPRB= prbGR.insert();
current.problem_id = newPRB;
current.update();
gs.addInfoMessage(gs.getMessage("Problem {0} created", prbGR.number));
action.setRedirectURL("incident.do?sys_id=" + current.sys_id.toString());
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2023 01:13 AM
Thank you so much for investing time on this. I found the issue. It was with setting the display value to true for a different field in the problem table instead of number field. Once the change is made to the table level columns the issue got resolved.