Reputation: 165
I've got a service running on my CQ5 istance and I want to invoke its method from a workflow. My question is, how can I get the reference of a service from a ECMA script?
I've already tried:
var myService= sling.getService(Packages.com.my.package.MyService.class);
but I get a "missing name after . operator" and
var myService= sling.getService(Packages.com.my.package.MyService);
but I get null reference.
Any idea?
Upvotes: 1
Views: 666
Reputation: 6100
I'm not sure how that works in CQ workflow ECMA scripts but in plain Sling server-side Javascript the sling.getService(Packages.com.example.MyServiceInterface)
syntax is correct.
Make sure the OSGi console at /system/console/services
shows an active service with the MyServiceInterface
.
Upvotes: 2