- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2020 02:27 PM
I am trying to call a Script Include from a business rule on a Madrid instance. The problem is that when I try to initialize it, I get the following error: "The undefined value has no properties". To rule out any issue from my own Script Include, here's an example using a built in (to Security Incident Response app) Script Include that throws the same error:
Business Rule:
Table: sn_si_incident
Application: Security Incident Response
Active: True
Advanced:True:
When to run:
When: After
Order: 100
Insert: True
<No Filter Conditions/Role Conditions>
(function executeRule(current, previous /*null when async*/) {
gs.warn("Calling incident utils");
var x = sn_si.SecurityIncidentUtils();
gs.warn("Successfully called incident utils");
})(current, previous);
Both the Script Include (sn_si.SecurityIncidentUtils) and my business Rule are in the Security Incident Response application. The first warn message prints,the second does not, and I get the following error in my log:
org.mozilla.javascript.EcmaError: The undefined value has no properties. Caused by error in sys_script_include.d22e7bdbc0a8016500a18e024bfc9aa3.script at line 4 1: (function executeRule(current, previous /*null when async*/) { 2: 3: ==> 4: gs.warn("Calling incident utils"); 5: var x = sn_si.SecurityIncidentUtils(); 6: gs.warn("Successfully called incident utils"); 7: |
On my New York Personal Developer instance, I get similar behavior, but I get an additional error message (in addition to the one above):
org.mozilla.javascript.EcmaError: The undefined value has no properties.
Caused by error in sys_ui_action.42da42d00a0a0b340066377beb6dd099.script at line 1
==> 1: (function executeRule(current, previous /*null when async*/) {
2:
3:
4: gs.warn("Calling incident utils");
I also tried removing the `sn_si` Script Include namespace: var x = SecurityIncidentUtils()
That did not change the errors.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 05:51 AM
The issue you are facing is because you are calling the script include but not callingthe function of Script Include which you wants to get executed.
Please refer to one of the OOB Business Rules where the same script include and function is being called and executed without any issues. The same was intended in my very first comment.
OOB Business Rule: Close child security incidents
Script:
// closes or cancels any active child SIs when the parent SI is closed or cancelled
function onAfter(current, previous) {
new sn_si.SecurityIncidentUtils().closeActiveChildSecurityIncidents(current);
new sn_si.SecurityIncidentUtils().closeAssessments(current.getUniqueValue());
}
So you can refer to the above script and see that the same script include "SecurityIncidentUtils" is called and the function "closeActiveChildSecurityIncidents" & "closeAssessments" is being called.
closeActiveChildSecurityIncidents: It closes all the active child records associated with the current record.
closeAssessments: Closes all the assessments of the child records.
Similarly you need to define the function which you want to be evaluated.
Kindly mark my answer as Correct and Helpful based on the Impact.
Regards,
Alok

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2020 03:10 PM
Could you please share latest code so that it will be easy to debug
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 05:00 AM
Alok - thanks for your interest in helping me solve this issue!
The code above will throw the error if you debug it. Here's the steps to reproduce it.
0. If you don't have the Security Incident Response plugin installed in your developer instance, install it.
1. Create a business rule that targets the sn_si_incident table. Have it run this script in `onAfter` for Inserts.
2. Paste the code:
(function executeRule(current, previous /*null when async*/) {
gs.warn("Calling incident utils");
var x = sn_si.SecurityIncidentUtils();
gs.warn("Successfully called incident utils");
})(current, previous);
3. Save the Business Rule
4. Insert a new security incident (Security Incident -> Show All Incidents. Then click the `New` button). It doesn't matter what's in the incident. I believe the only required field is the Short Description.
4. Inspect the instance log (System Logs -> All) and you will see the first message print, and then you will see the error messages. The second message doesn't print.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 05:51 AM
The issue you are facing is because you are calling the script include but not callingthe function of Script Include which you wants to get executed.
Please refer to one of the OOB Business Rules where the same script include and function is being called and executed without any issues. The same was intended in my very first comment.
OOB Business Rule: Close child security incidents
Script:
// closes or cancels any active child SIs when the parent SI is closed or cancelled
function onAfter(current, previous) {
new sn_si.SecurityIncidentUtils().closeActiveChildSecurityIncidents(current);
new sn_si.SecurityIncidentUtils().closeAssessments(current.getUniqueValue());
}
So you can refer to the above script and see that the same script include "SecurityIncidentUtils" is called and the function "closeActiveChildSecurityIncidents" & "closeAssessments" is being called.
closeActiveChildSecurityIncidents: It closes all the active child records associated with the current record.
closeAssessments: Closes all the assessments of the child records.
Similarly you need to define the function which you want to be evaluated.
Kindly mark my answer as Correct and Helpful based on the Impact.
Regards,
Alok
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 10:21 AM
Alok - thanks for the help!
I was playing around with your solution and realized that I was missing the `new` keyword in front of my object creation!
I had:
var x = sn_si.SecurityIncidentUtils();
and I had just forgotten and kept missing that I had forgotten the new keyword:
var x = new sn_si.SecurityIncidentUtils();
If you want to update your answer to mention that, I'll then mark it as the correct answer.
Thanks!
Craig

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2020 11:22 AM