Skip to main content
15-Moonstone
August 20, 2021
Solved

.js Function Exection on Service Completion

  • August 20, 2021
  • 1 reply
  • 2737 views

How would I code a function to execute every time a service is completed? I would like to use js instead of bindings.

Best answer by ailko

To execute javascript code in studio home.js when a TWX service added in the External Data would trigger a "ServiceInvokedComplete" event you can add the following in the home.js to intercept that event and run code that doesn't require leveraging the bindings in studio:

 

$scope.$on('myTWXService.serviceInvokeComplete', function(evt, arg)
{
// do code after myTWXService executes
});

1 reply

ailko5-Regular MemberAnswer
5-Regular Member
August 20, 2021

To execute javascript code in studio home.js when a TWX service added in the External Data would trigger a "ServiceInvokedComplete" event you can add the following in the home.js to intercept that event and run code that doesn't require leveraging the bindings in studio:

 

$scope.$on('myTWXService.serviceInvokeComplete', function(evt, arg)
{
// do code after myTWXService executes
});

Ike@ACE15-MoonstoneAuthor
15-Moonstone
August 24, 2021

What are the two parameters that are passed into the function (i.e. evt and arg)?

5-Regular Member
August 24, 2021

This is just the OOTB function definition for the serviceInvokedComplete trigger in Studio, as far as the values I've never needed to leverage them for my usecases or know what their values are but you can use console.log() in the home.js and the values will show up in the Console tab of dev tools. ie console.log(evt)