
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2021 03:40 PM
Hi Guys, i have imported psl
that's a JavaScript
domain name parser based on the Public Suffix List in a Script Include.
The script include testing works correctly in a fix script but i receive "the undefined value has no properties" when i try to call it into a Business Rule.
Script Include pslv182 is attached, Application GLOBAL Accessible from "ALL APPLICATION SCOPES"
===========FIX SCRIPT===================
gs.include('pslv182');
var parsed = psl.parse('titolari.info.legacyconstructionok.com');
gs.print(parsed.tld); // 'com'
gs.print(parsed.sld); // 'google'
gs.print(parsed.domain); // 'google.com'
gs.print(parsed.subdomain); // null
========================================
And it'works GREAT!
Script:
Completed: Event Management - process events in 0:00:00.022, next occurrence is 18/02/2021 00:22:31
Completed: Pick up throttled integration process in 0:00:00.024, next occurrence is 18/02/2021 00:22:28
isValid(): entered for connection 15 (connpid=3677415)
Completed: Service Mapping - check for changes in t in 0:00:00.008, next occurrence is 18/02/2021 00:22:31
isValid(): Connection 15 is valid (connpid=3677415)
Completed: Error Manager - retry discovery on all p in 0:00:00.008, next occurrence is 18/02/2021 00:23:26
*** Script: com
*** Script: legacyconstructionok
*** Script: legacyconstructionok.com
*** Script: titolari.info
[0:00:00.397] Total Time
By the way it stucks in a Business Rule (Application Security Incident Response)
================Business Rule================
(function executeRule(current, previous /*null when async*/) {
var gr = new global.pslv182();
var parsed = gr.psl.parse('titolari.info.legacyconstructionok.com');
gs.info('CHECK PKR TLD: '+parsed.tld); // 'com'
gs.info('CHECK PKR SLD: '+parsed.sld); // 'google'
gs.info('CHECK PKR DOMAIN: '+parsed.domain); // 'google.com'
})(current, previous);
===========================================
============ERROR LOG=====================
18/02/2021 00:35:30
|
fabrizio.francavilla | Warning | org.mozilla.javascript.EcmaError: The undefined value has no properties. Caused by error in sys_script.3c9d1b871b1ee450af04975e0d4bcba4.script at line 5 2: 3: var gr = new global.pslv182(); 4: ==> 5: var parsed = gr.psl.parse('titolari.info.legacyconstructionok.com'); 6: gs.info('CHECK PKR TLD: '+parsed.tld); // 'com' 7: gs.info('CHECK PKR SLD: '+parsed.sld); // 'google' 8: gs.info('CHECK PKR DOMAIN: '+parsed.domain); // 'google.com' |
Any suggestion??
Many thanks!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-19-2021 07:21 AM
In the fix script example, you loaded the library like this:
gs.include('pslv182');
Whereas in your business rule you are trying to instantiate it using the keyword new, and it seems it cannot work that way.
Have you tried the gs.include syntax in the business rule?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2021 01:16 AM
Hi Slava, thanks for you reply! I have made a try and this is logging result...
18/02/2021 10:12:15
|
fabrizio.francavilla | Warning | org.mozilla.javascript.EcmaError: Method "toString" called on incompatible object. Caused by error in sys_script.3c9d1b871b1ee450af04975e0d4bcba4.script at line 1 ==> 1: (function executeRule(current, previous /*null when async*/) { 2: 3: var gr = new global.pslv182(); 4: gs.info('Print status gr'+gr); |
Evaluator |
18/02/2021 10:12:15
|
fabrizio.francavilla | Warning | org.mozilla.javascript.EcmaError: Method "toString" called on incompatible object. Caused by error in sys_script.3c9d1b871b1ee450af04975e0d4bcba4.script at line 4 1: (function executeRule(current, previous /*null when async*/) { 2: 3: var gr = new global.pslv182(); ==> 4: gs.info('Print status gr'+gr); 5: var parsed = gr.psl.parse('titolari.info.legacyconstructionok.com'); 6: gs.info('CHECK PKR TLD: '+parsed.tld); // 'com' 7: gs.info('CHECK PKR SLD: '+parsed.sld); // 'google' |
Evaluator |

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2021 01:32 AM
18/02/2021 10:28:12
|
gianluca.devito-c | Information | Print status grundefined | sn_si |
BTW the value in gr is "undefined"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2021 01:37 AM
Hi,
can you try to add try catch block to know the exception
Also can you try to call it from some other custom scope from background scripts
Also what is psl ?
you are trying to call the parse() function but what is the prefix psl
(function executeRule(current, previous /*null when async*/) {
try{
var gr = new global.pslv182();
var parsed = gr.psl.parse('titolari.info.legacyconstructionok.com');
gs.info('CHECK PKR TLD: '+parsed.tld); // 'com'
gs.info('CHECK PKR SLD: '+parsed.sld); // 'google'
gs.info('CHECK PKR DOMAIN: '+parsed.domain); // 'google.com'
}
catch(ex){
gs.info('Exception'+ex);
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2021 02:00 AM
18/02/2021 10:56:17
|
fabrizio.francavilla | Information | ExceptionConversionError: The undefined value has no properties. | sn_si |
This is logging...
BTW psl is what i have called into fix scritp to testing:
==========fix script==============
gs.include('pslv182');
var parsed = psl.parse('titolari.info.legacyconstructionok.com');
gs.print(parsed.tld); // 'com'
gs.print(parsed.sld); // 'google'
gs.print(parsed.domain); // 'google.com'
gs.print(parsed.subdomain); // null
================================
Did you see the Script include attached? It's a library included into SI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2021 02:09 AM
Hi,
I tried pasting it in the script include but since it has more lines of code page became unresponsive
can you share the screenshot of the script include along with highlighting that parse function
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader