0 votes
1.6k views
in Integrations by

1 Answer

0 votes
by (30.6k points)

tw.system.executeServiceByName(name, inputs) runs a service (service flow / general system service) from a server-side script and returns its outputs - useful for dynamic dispatch (the service to run is decided by data). Signature and use:

// server-side script (service flow / BPD script task)
var inputs = new tw.object.Map();                 // inputs by parameter name
inputs.put("customerId", tw.local.order.customerId);
inputs.put("includeHistory", true);
var result = tw.system.executeServiceByName("Get Customer Details", inputs);   // name of the service in the same process app or a dependent toolkit
tw.local.customer = result.get("customer");       // outputs come back as a Map keyed by output parameter name
tw.local.found    = result.get("found");

// dynamic dispatch: service name from configuration
var handler = tw.epv.Routing["handler_" + tw.local.order.type];   // e.g. "Handle Standard Order" / "Handle Express Order"
var out = tw.system.executeServiceByName(handler, inputs);

Details: inputs are matched by parameter name (unmatched inputs are ignored, missing ones get defaults); business objects are passed by reference to the called service, which runs synchronously in the same transaction and thread; errors thrown inside surface as JavaScript exceptions in the caller (wrap with try / catch); the service is resolved in the current snapshot (toolkit services included). Not available in client-side scripts (browser) - there use a service flow call from the CSHS or the Service Call control. Prefer a modelled nested service call when the target is static: it is visible in the diagram, validated, and refactoring-safe; executeServiceByName is for genuinely dynamic cases, and renaming a service silently breaks callers - keep the names in one EPV.

References

Related questions

0 votes
1 answer 2.0k views
0 votes
1 answer 2.1k views
+1 vote
1 answer 1.3k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...