- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2018 02:09 AM
At the moment I have a calculation on the field to work out the percentage of a contracts consumed value.
(function calculatedFieldValue(current) {
var consumedper = current.u_consumed_hours / current.u_total_hours*100;
return consumedper;
})(current);
I'm no good with making business rules unless its fairly simple functional stuff e.g. if somethings x it sets another field to y.
I also want to include this into an event for email notifications.
Can anyone help it would be greatly appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2018 02:17 AM
Hi Andrew,
Where do you want that calculation to be performed?
Do you want calculation to happen when record inserted/updated? If yes then you can have this in before insert/update business rule
Sample script:
var consumedper = current.u_consumed_hours / current.u_total_hours*100;
current.<percentageField> = consumedper;
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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
‎11-05-2018 02:17 AM
Hi Andrew,
Where do you want that calculation to be performed?
Do you want calculation to happen when record inserted/updated? If yes then you can have this in before insert/update business rule
Sample script:
var consumedper = current.u_consumed_hours / current.u_total_hours*100;
current.<percentageField> = consumedper;
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
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
‎11-05-2018 02:27 AM
That worked a treat, thank you!
How do I trigger an event from that? I'm looking for something to trigger on 50% 60% 70% 80% 90% 100%
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-05-2018 03:07 AM
Great that it worked.
Can you mark my answer as correct and helpful.
Also for triggering the notification on particular percentage reach you can use workflow.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader