instanceOf in scoped application

ssturde
Kilo Expert

I have a copy of a UI action in my new scoped application that uses the function 'instanceOf'. It works fine in the global scope, but not inside the scope. It's in my condition statement, and I'm wondering if there is a scoped alternative for it. Here's the condition statement:

current.canCreate() && (!current.instanceOf('task') || gs.getProperty('glide.ui.task.insert') == 'true') && (!current.instanceOf('sys_db_object')) && !current.x_elar_metrix_ela_record ==''

Any help is greatly appreciated.

1 ACCEPTED SOLUTION

ericeger
Tera Guru

Hi Stephen,



I think you should be able to use current.sys_class_name != 'task' instead of instanceOf within a scoped application.  



Eric


View solution in original post

6 REPLIES 6

ericeger
Tera Guru

Hi Stephen,



I think you should be able to use current.sys_class_name != 'task' instead of instanceOf within a scoped application.  



Eric


Thanx, that did it. I ran into another one.



I have a business rule inside the scope that translates a duration value to an integer, but the 'getGlideObject()' function isn't available inside the application scope. I've tried 'getDisplayValue()' and 'getValue()' but neither return.



Here's how I'm using it:



var scheduledDuration = current.u_scheduled_downtime.getGlideObject().getNumericValue();


var scheduledDurationMinutes = (scheduledDuration/1000/60);


current.u_minutes_downtime = scheduledDurationMinutes.toFixed();


current.update();



Any ideas on a replacement function inside app scope?


Hey Stephen,



Unfortunately, the only way I've found you can run 'getGlideObject()' on a scoped application record is through a Rest API call into the current table and creating a response call that allows you to run a script that contains 'getGlideObject() to get a numericValue and convert it into a schedule duration.   Have you tried .getNumericValue() without the getGlideObject?


I have tried 'getNumericValue()' directly on the field, but it doesn't return a value. Just shooting in the dark, I tried 'dateNumericValue()' and it worked! Here's the end result code:



var actualDuration = current.u_actual_downtime.dateNumericValue();


var actualDurationMinutes = (actualDuration/1000/60);


current.u_minutes_downtime = actualDurationMinutes.toFixed();


current.update();