Target automation script for benefit plans
reference australia Updated Sep 10, 2026 1 min read target-automation-script-benefit-plans-apw.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:Form field information for Strategic Planning
49 lines · 2.4 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/scenario-planning-in-spw/target-automation-script-benefit-plans-apw.html
release: australia
product: Scenario Planning in SPW
classification: scenario-planning-in-spw
topic_type: reference
last_updated: "2026-09-10"
reading_time_minutes: 1
breadcrumb: [Form field information for Strategic Planning, Reference, Portfolio Planning in Strategic Planning Workspace, Strategic Planning, 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:**[Form field information for Strategic Planning](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-business-management/scenario-planning-in-spw/form-field-information-for-strategic-planning.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/scenario-planning-in-spw/target-automation-script-benefit-plans-apw.html |
| release | australia |
| product | Scenario Planning in SPW |
| classification | scenario-planning-in-spw |
| topic_type | reference |
| last_updated | 2026-09-10 |
| reading_time_minutes | 1 |
| breadcrumb | Form field information for Strategic PlanningReferencePortfolio Planning in Strategic Planning WorkspaceStrategic PlanningStrategic Portfolio Management |