Calculate and populate a field on story form based on scrum tasks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-02-2022 11:49 PM
Hi all,
The requirement is- I have a field named as 'Efforts' on story form.
I want to calculate the sum of actual hours of all scrum tasks for a story record and populate the calculated value in 'Efforts' field.
For eg- if i have 3 scrum tasks- A,B,C for a story record-'test' having actual hours as 2,4,6. I want to calculate the sum of actual hours of all three scrum tasks(A+B+C i.e 2+4+6=12) and populate calculated value(12) in 'Efforts' field of story- test.
Could someone help me to achieve this?
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2022 01:04 AM
Hi,
yes
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var hours = 0;
var gr = new GlideRecord("rm_scrum_task");
gr.addQuery("story", current.story);
gr.query();
while(gr.next()) {
hours = hours + gr.hours;
}
var storyRec = current.story.getRefRecord();
storyRec.effort = parseInt(hours);
storyRec.update();
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 12:53 AM
still decimal value is populating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 01:09 AM
Hi,
what is the field type for effort on story table?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 01:42 AM
string field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2022 01:45 AM
then it should work.
Can you share the exact script?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader