I have a scope call services within my solution.
I am creating a headless client based on same solution and when i try to queue a function from my scopes.services i get the following
callback data, name: global methodname: doTest didnt resolve to a method in solution scm_riscm
Is there a special notation to use to queue a function from a new scope?
For smart and web clients, the context is the entire solution…all modules. Headless client the context is only the module (and modules included in it) that you specify in the session:
All the code is contained within the same solution, no module calls are made.
My code is declared in a scope of the same solution started as a headless client hence i am stumped.
All the code is contained within the same solution, no module calls are made.
My code is declared in a scope of the same solution started as a headless client hence i am stumped.
If that’s the case then, without testing I suspect that only global and form methods are available to headless client. These work for sure:
// Method on a form set with setMainForm(formName)
String results = (String)servoy_hc.executeMethod(null, "aMethod", new Object[]{session, request});
// Method on a form passed in
String results = (String)servoy_hc.executeMethod("formName", "aMethod", new Object[]{session, request});
// Global method
IDataSet results = (IDataSet)servoy_hc.executeMethod(null, "globals.aMethod", new Object[]{session, request});
Not sure about (and would be surprised if they did):
// Work?
IDataSet results = (IDataSet)servoy_hc.executeMethod(null, "scopes.scopeName.aMethod", new Object[]{session, request});
// Work?
IDataSet results = (IDataSet)servoy_hc.executeMethod(null, "globals.scopes.scopeName.aMethod", new Object[]{session, request});
For headless client work, we long ago started using forms to organize code available to the headless client. Kind of like a poor man’s “public” API organization. If you get scopes to work though, that would be ideal.
We have created a handler/routing function in the main globals scope to call the method we require in the new scope.
All we are doing is passing the parent scope name, object name and function name as parameters.
var pa = {paramsArr:paramsArr,parentScope:'services',parentObj:'METHODS',func:methodName}
h.queueMethod(null,'ROUTING',[pa],doCallBack)
and in main globals scope we have
function ROUTING(obj){
return scopes[obj.parentScope][obj.parentObj][obj.func](obj.paramsArr)
}
Cool, so scopes work. Sounds like just need to play around with where to put the callback method. Too bad specifying the callback method isn’t done the same way as specifying the trigger method. Would make all the routing a lot easier to figure out.