Target automation script for benefit plans
reference australia Updated Sep 10, 2026 1 min read target-automation-script-benefit-plans.md
Use the predefined Benefit Plans script as a target source to automate the actual value of your targets from the benefit plans of relevant work items.
Use the following predefined benefit plans script to configure the target source for your targets. The script fetches the required data for monetary or non-monetary benefit plans and updates the actual value for the target. You can use this script as is or you can also modify it according to your requirement. You can also create context variables and configure them for this target source (Benefit Plans).
JavaScript
result = '';var benefitPlans = new GlideRecord(sn_gfa.GFAdvancedConstants.BENEFIT_PLAN_TABLE);benefitPlans.addQuery('sys_id', 'IN', benefit_plan);benefitPlans.query();
var nonMonetaryBenefitSum = 0;var monetaryBenefitSum = 0;var hasMonetary = false;var hasNonMonetary = false;while (benefitPlans.next() && !(hasMonetary && hasNonMonetary)) { if (!gs.nil(benefitPlans.getValue('currency'))) { monetaryBenefitSum += parseInt(benefitPlans.getValue('actual_benefit')); hasMonetary = true; } else { nonMonetaryBenefitSum += parseInt(benefitPlans.getValue('nm_actual_benefit')); hasNonMonetary = true; }}
if (hasMonetary && hasNonMonetary) gs.addErrorMessage(gs.getMessage('The Benefit Plan list can contain either monetary or non-monetary benefit plans.'));else result = hasMonetary ? monetaryBenefitSum : nonMonetaryBenefitSum;Parent Topic:Goal Framework and Goal Framework for SPM reference
49 lines · 2.3 KB
---
title: Target automation script for benefit plans
description: Use the predefined Benefit Plans script as a target source to automate the actual value of your targets from the benefit plans of relevant work items.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/it-business-management/goal-framework/target-automation-script-benefit-plans.html
release: australia
product: Goal Framework
classification: goal-framework
topic_type: reference
last_updated: "2026-09-10"
reading_time_minutes: 1
breadcrumb: [Reference, Goal Framework and Goal Framework for SPM, Strategic Portfolio Management]
---
# Target automation script for benefit plans
Use the predefined Benefit Plans script as a target source to automate the actual value of your targets from the benefit plans of relevant work items.
Use the following predefined benefit plans script to configure the target source for your targets. The script fetches the required data for monetary or non-monetary benefit plans and updates the actual value for the target. You can use this script as is or you can also modify it according to your requirement. You can also create context variables and configure them for this target source \(Benefit Plans\).
```
result = '';
var benefitPlans = new GlideRecord(sn_gfa.GFAdvancedConstants.BENEFIT_PLAN_TABLE);
benefitPlans.addQuery('sys_id', 'IN', benefit_plan);
benefitPlans.query();
var nonMonetaryBenefitSum = 0;
var monetaryBenefitSum = 0;
var hasMonetary = false;
var hasNonMonetary = false;
while (benefitPlans.next() && !(hasMonetary && hasNonMonetary)) {
if (!gs.nil(benefitPlans.getValue('currency'))) {
monetaryBenefitSum += parseInt(benefitPlans.getValue('actual_benefit'));
hasMonetary = true;
} else {
nonMonetaryBenefitSum += parseInt(benefitPlans.getValue('nm_actual_benefit'));
hasNonMonetary = true;
}
}
if (hasMonetary && hasNonMonetary)
gs.addErrorMessage(gs.getMessage('The Benefit Plan list can contain either monetary or non-monetary benefit plans.'));
else
result = hasMonetary ? monetaryBenefitSum : nonMonetaryBenefitSum;
```
**Parent Topic:**[Goal Framework and Goal Framework for SPM reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-business-management/goal-framework/goal-framework-reference.md)
| title | Target automation script for benefit plans |
| description | Use the predefined Benefit Plans script as a target source to automate the actual value of your targets from the benefit plans of relevant work items. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/australia/it-business-management/goal-framework/target-automation-script-benefit-plans.html |
| release | australia |
| product | Goal Framework |
| classification | goal-framework |
| topic_type | reference |
| last_updated | 2026-09-10 |
| reading_time_minutes | 1 |
| breadcrumb | ReferenceGoal Framework and Goal Framework for SPMStrategic Portfolio Management |