Dongzhi Yang7528784
Posts: 0
Joined: Mon May 11, 2015 6:28 am

using library

Hi Support team,

I want to create some custom functions and global constant variables that can be used by all server code script. So I build a library with the following:

-----------------------------

var glob=(function(){

return{ "variable1":"value1",
"variable2":"value2",
"function1":function(p1,p2){//do something}}

})();

---------------------

but when i try to use 'glob' in my script, it always says that 'glob' is not defined.
Could you let me know what went wrong?

Thanks

Dongzhi

Dongzhi Yang7528784
Posts: 0
Joined: Mon May 11, 2015 6:28 am

using library

Hi Team,

Anyone shed a light? I have tried to use the way how moment.js is exposing its function. But I still can't get it to work.

Could you give an example on how to use library?

Thanks

Dongzhi

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

using library

Hi Dongzhi -

I'm not sure if the global scope is available for server script code, we will need to clarify this with our backend developers team.

Dongzhi Yang7528784
Posts: 0
Joined: Mon May 11, 2015 6:28 am

using library

Hi lllya,

I have solved the issue. I set "dependencies" on the service script to be dependent on the library, then it works now.

Any my library has been modified to the following:

-------

(function(){

this['settings']={ "variable1":"value1",
"variable2":"value2",
"function1":function(p1,p2){//do something}}

}).call(this);

--------------

Thanks

Dongzhi

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

using library

Hi Dongzhi,

Thank you for the update!

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

using library

Here is what we have for data transfer between the server scripts: https://devcenter.appery.io/documenta...

I'm afraid that there is no other way to call a script from another.

Maybe also this one: https://devcenter.appery.io/documenta... - data can be transmitted through the request parameters. And no global variables will be needed in this way.

Return to “Issues”