Receiving error "the undefined value has no properties" calling script include from Business Rule

Fabrizio1
Tera Contributor

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=====================

Any suggestion??

Many thanks!

1 ACCEPTED SOLUTION

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?

View solution in original post

15 REPLIES 15

Hi, is too big to include a screenshot! Indeed I've attached it for any kind of testing. Try to import into a Script Include taking all the code with CTRL+A then CTRL+C + CTRL+V

find_real_file.pngfind_real_file.pngfind_real_file.pngfind_real_file.pngfind_real_file.pngfind_real_file.pngfind_real_file.png

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?

Hi Slava, i have solved before i have read your answer but it was exactly the solution. 😉

BTW The Script Inculde and the Business rules have to stay in Global application.

They doesn't work if run into Security Incident Response. Probably something declared as global directly into javascript psl.

Many thanks!

Ankur Bawiskar
Tera Patron
Tera Patron

@Fabrizio 

Can you try to create Cross Scope Privilege record for that script include

1) Ensure you are in Application Security Incident Response Scope

2) Then in left navigation type cross

3) Create new entry with details below

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader