- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2014 07:24 AM
I don't know if this is possible but lets say I have 5 fields on a form each of which are called field 1 to 5 respectively and I want to add them and put the sum in field 6.
I've seen the WIKI Article GlideAggregate - ServiceNow Wiki but don't know if that will work for me as I'm a javascript idiot.
Does anyone have any suggestions as to how best I can approach this please?
TIA
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 01:57 AM
Copy paste this code and check
var a = parseInt(current.u_initiation_days_);
var b = parseInt(current.u_development_days_);
var c = parseInt(current.u_configuration_days_);
var d = parseInt(current.u_testing_uat_days_);
var e = parseInt(current.u_pm_days_);
var f = parseInt(current.u_external_days);
var g = parseInt(a)+parseInt(b)+parseInt(c)+parseInt(d)+parseInt(e)+parseInt(f);
gs.log('Total :'+g);
current.u_total_days = g;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2014 08:21 AM
Harish I created the following business rule after making Alex's script inactive and it fails for me, any ideas?
Before insert, update and delete
var a = parseInt(g_form.getValue('u_initiation_days_'));
var b = parseInt(g_form.getValue('u_development_days_'));
var c = parseInt(g_form.getValue('u_configuration_days_'));
var d = parseInt(g_form.getValue('u_testing_uat_days_'));
var e = parseInt(g_form.getValue('u_pm_days_'));
var f = parseInt(g_form.getValue('u_external_days'));
var g = a+b+c+d+e+f;
g_form.setValue('u_total_days',g);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-17-2014 08:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 01:50 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 01:57 AM
Copy paste this code and check
var a = parseInt(current.u_initiation_days_);
var b = parseInt(current.u_development_days_);
var c = parseInt(current.u_configuration_days_);
var d = parseInt(current.u_testing_uat_days_);
var e = parseInt(current.u_pm_days_);
var f = parseInt(current.u_external_days);
var g = parseInt(a)+parseInt(b)+parseInt(c)+parseInt(d)+parseInt(e)+parseInt(f);
gs.log('Total :'+g);
current.u_total_days = g;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2014 02:08 AM
Thanks Harish that worked fine, looks like I just needed to replace the var g line with yours.
Thank you all for your help