Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

gs.getProperty + script include + navigator application Menu Module

poyntzj
Kilo Sage

The client has an application in the navigator to show their tickets.

One of these runs from a database view linking tasks to SLA's and so on.

I reworked it a little while ago to use a script include instead of a number of filters and it runs happily

For some new features, I need to be able to do a few more advanced queries based on a function which then determines what values i look for in a field and indeed what tables get queries.

So instead of having to rewrite this each time, i am a fan of trying to read data from a table or the sys properties so the code remains and the results can be extended or tweaked by adding / modifying data (and therefore no Change Requests)

so, my code is running fine when I run it as a backgroun script

gs.log(new myWorld().mine())

and in this case it is limited to returning me some CHG records

*** Script: myWorld mine : e89170136fe2ca40e87f715dbb3ee4c2 : true : true : it : IT : change_request

*** Script: CHG0036974,CHG0036908,

In the script, the user Id is obtained by gs.getUserID()

the groups are obtained by a gs.getUser().getMyGroups() call

and in the above I am using gs.getProperty to read some values from the sys_properties table

Now, if I run it from the navigator application module, it is not perform any ANY of the gs.getProperty calls

I can tell this as if I leave it to run, I see no records.

If I put some values in it then returns data

I also tried to query directly against the sys_properties table and it still seems to return no values

So why can it get the userId and groups, but not these properties ?

also I am struggling to do any debug on it as when it runs as a background script the gs.log line prints and adds to the script log, but when called from the app menu it does not.

any ideas anyone ?

1 ACCEPTED SOLUTION

poyntzj
Kilo Sage

In the end I have created a new table to do this


propertyname                   value



Running a gliderecord query against that works


no idea why gs.getProperty fails.


View solution in original post

9 REPLIES 9

poyntzj
Kilo Sage

In the end I have created a new table to do this


propertyname                   value



Running a gliderecord query against that works


no idea why gs.getProperty fails.


Hi Julian,



Is it possible your code is running client-side?



You cannot use gs.getProperty() client-side but there is a client-side GlideRecord that would still run, allowing you to query... That might explain the disparity.



It also explains why other glidesystem calls are not working (log, etc.)



Thanks,


-Brian


Hi Brian


I did think that so I had a try / catch around the gs.getproperty so if there is an error, or the resulting value was empty, then it will call AJAX routine I have (I pass what property I am after and it returns the value)


That did not work either



It is not a rights issue as I was testing with my account which is an admin


also trying to use a glidrrecord against sys_properties itself did not work.



i have it working via the new table so no great issue - just annoying


Oh well back here again for something else.


I have a script include which at one point was just a function,. now it is a class



first one


function getPropertySI()


{


return 'fred';


}


second one


var getPropertySI = Class.create();


getPropertySI.prototype = {


      doit: function() {


              return 'fred';    


      },


      type: 'getPropertySI'


};



both via a background script return the value I expect


putting this as a filter on a navigator menu and it returns fred via both methods



i try this


var getPropertySI = Class.create();


getPropertySI.prototype = {


      doit: function() {


              var strReturn = gs.getProperty("instance_name");


              return 'fred ' + strReturn;      


      },


      type: 'getPropertySI'


};


and I can see I get 'fred ' undefined



works fine as a background script and is not a rights issue as i am running as myself.



Any ideas ?