Business rule that used GlideDate().getDisplayValue() fails in Istanbul

perkinsarm
Mega Guru

We are upgrading from Fuji to Istanbul.

A business rule within a scoped application (delivered by ServiceNow) sets a Date Completed value when a record is Closed.

This ran fine on Fuji but displays the error "Illegal access to method getDisplayValue() in class com.glide.glideobject.GlideDate." on Istanbul.


Error logs show:

java.lang.SecurityException: Illegal access to method getDisplayValue() in class com.glide.glideobject.GlideDate

Caused by error in <refname> at line 1

==> 1: GlideDate().getDisplayValue()

The business rules action is

Set field values [Date Completed] [To] [javascript:   GlideDate().getDisplayValue()]

Is there a way I can make this allowed without changing the script?

If not, can someone suggest an alternate solution that would be allowed.

1 ACCEPTED SOLUTION

Hi Bradley,



My bad, I didn't get that. Could you please try using the Script in the 'Advanced' tab. I believe the Business rule if of before type. Please remove the Set Field Values and use the script as below:


current.field_name_of_date_completed = new GlideDateTime().getDisplayValue();



I hope this helps.Please mark correct/helpful based on impact


View solution in original post

4 REPLIES 4

amlanpal
Kilo Sage

Hi Bradley,



Could you please provide the script of the same. Also it would be something like below,


var date =   new GlideDateTime().getDisplayValue();



I hope this helps.Please mark correct/helpful based on impact


Amlan,



There isn't an actual script defined. The javacript is inline in the Business Rule' Action:



find_real_file.png



What are you suggesting I try? Thanks!


Hi Bradley,



My bad, I didn't get that. Could you please try using the Script in the 'Advanced' tab. I believe the Business rule if of before type. Please remove the Set Field Values and use the script as below:


current.field_name_of_date_completed = new GlideDateTime().getDisplayValue();



I hope this helps.Please mark correct/helpful based on impact


Amlan,



I thought that is what you might have meant and have since removed the action and created the following script in the business rule.


For some reason this isn't illegal? Problem solved. Will mark your answer correct.



function onBefore(current, previous) {


  // Originally set date_completed in this Business rule's Action:


  // Set field values [Date Completed] [To] [javascript:   GlideDate().getDisplayValue()]


  // That would create error's whe we upgraded to Istanbul


  //


  // This script achieves the same result and for some reason is not illegal.


  //


  // See INC0010831. 2017-06-14, brad.perkins


  var date =   new GlideDateTime();


  current.date_completed = date.getDisplayValue();


}