Extending the Javascript with custom functionality in script tasks

Hello everyone! I would like to do something a bit strange. Essentially I want to call a javascript function from outside the script task and pass data through the function parameters. Example:

function foo(json) {
   if(json.people[0].name === 'Steve') {
         return 55;
    } 
}

I then want this return value to be returned to wherever the function was called. If this is possible through API calls it’d be optimal, but I understand if it’s not possible due to the niche nature of it

Thanks!

Hello my friend! Welcome to Camunda Community \o/
Sorry, but I don’t think I quite understand what you need.

Could you give a better example, perhaps illustrating it with a BPMN?

Where is this function you want to call implemented?
You said it’s “outside your script task”, but where exactly is it?

William Robert Alves