--- title: Providing a script for custom task recommendation criteria description: Guidelines for creating scripts in recommendation criteria for an Intelligent Task Recommendation policy. locale: en-US canonical_url: https://www.servicenow.com/docs/r/australia/field-service-management/field-service-scheduling/script-guidelines-recommendation-criteria.html release: australia product: Field Service Scheduling classification: field-service-scheduling topic_type: reference last_updated: "2026-03-12" reading_time_minutes: 1 breadcrumb: [Configure Intelligent Task Recommendations, Setting up a Field Service scheduling method, Configure, Field Service Management] --- # Providing a script for custom task recommendation criteria Guidelines for creating scripts in recommendation criteria for an Intelligent Task Recommendation policy. ## Customization script return object Your script should return a JavaScript object in a minimum form as follows: ``` { "": { "rating": }, "”: { "rating": }, … } ``` For filter constraints, set the return objects rating to one to unify the filter constraint result of the recommendation criteria by using the sn\_task\_recommend.TaskRecommendationUtil.setRatingToOne\(your object\); method. To normalize the rating result of ranking criteria, the return JavaScript object should include normalization information. ``` { "": { "rating": , "normalizationData": { "numerator": , "denominator": } }, "": { "rating": , "normalizationData": { "numerator": , "denominator": } }, ... } ``` For ranking criteria, the return object can contain data for final normalization. **Note:** If your scripts include normalization data, you can refer to the default script includes in the predefined recommendation criteria: - The filtering constraint Exclude tasks agent cannot travel to: sn\_fsm\_task\_rec.TaskRecommendationDistanceRuleProcessor - The ranking criteria Distance from task: rankTaskOnDistance\(\) ## Customized script in recommendation criteria The following example shows how to write a script for the recommendation criteria. ``` var customizedScript = ; var customizedResult = customizedScript.(); ruleResult = TaskRecommendationFSMUtil.parseRuleResult(customizedResult, ""); ``` The following sample configuration provides a "distance from task" filter constraint. ``` var distanceRule = new TaskRecommendationDistanceRuleProcessor(args); var ruleProcessResult = distanceRule.processRule(user, tasks, timeStart, timeEnd, 'ranking'); ruleResult = TaskRecommendationFSMUtil.parseRuleResult(ruleProcessResult, "Distance from task"); ``` **Note:** Do not replace the task recommendation application keyword `ruleResult` in the script with any other words. Otherwise, the application will not be able to process the rule execution result.