The 'Short Description' field from the release parent is not populating the 'Project Name' field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Hi,
I'm trying to configure the 'Short Description' field from the release parent to populate the 'Project Name' field in related tasks. However, the current business rule is incorrectly updating the related tasks using the 'Description' field from the related phase task instead of the release parent.
table: rm_task
when: display
script:
Regards
CarolMa
- Labels:
-
Release Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
your business rule should work if
1) you are clicking New button in related list of rm_task
2) if the parent has short_description populated
If you are not using New button for testing then make your BR as Before Insert and Not Display
Even after that it will work only when Parent is having short description
what debugging did you do? share some screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
Try the below updated script.
Use a Before Insert/Update BR + replace direct reference with getRefRecord() + check isValidRecord().
(function executeRule(current, previous /*null when async*/) {
if (current.parent) {
var parentGr = current.parent.getRefRecord(); // safely fetch parent
if (parentGr.isValidRecord()) {
current.u_project_name = parentGr.short_description;
}
})(current, previous);
Hope it helps!
Shashank Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago - last edited 4 weeks ago
I believe you are trying to create a related planned task 'pm_project' when 'rm_task' record is inserted.
Please see below for business rule and sample record for testing. I have created before BR on insert condition and you can add filter conditions [for example, check rm_task parent field is not empty] as per your requirements.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var grProject = new GlideRecord('pm_project');
grProject.initialize();
grProject.short_description = current.parent.short_description;
grProject.parent = current.sys_id;
grProject.insert();
})(current, previous);
Please note, as part of testing I have disabled 'Update Total Plan Cost In Proj Currency' BR in my PDI as it checks additional information before inserting a record in pm_project table. You can extend the logic accordingly.
If this helped to answer your query, please mark it helpful & accept the solution.
Thanks,
Bhuvan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 weeks ago
@Bhuvan @Shashank_Jain @Ankur Bawiskar
Release record (Parent) label Project name, name: ‘short_description’
Release phase record label: Project name and name: ‘short_description’
Related release task record, project name taken from the project phase
Table: rm_task
When: before
When to run insert and update
Script:
(function executeRule(current, previous /*null when async*/ ) {
if (current.parent) {
var parentGr = current.parent.getRefRecord(); // safely fetch parent
if (parentGr.isValidRecord()) {
current.u_project_name = parentGr.short_description;
gs.log("Release Task BR: Project name set to '" + current.u_project_name + "'");
} else {
gs.log("Release Task BR: Parent record is invalid.");
}
} else {
gs.log("Release Task BR: No parent Release associated with this Release Task.");
}
})(current, previous);
dont why its populating the release phase task short description and not the release(parent) record
Regards
CarolMa