How can I access to camunda scope "cam-script" in my custom script?

Hi Community

I am developing a custom angular js module to act as a helper and template for my embedded forms.
How can I access to camunda scope in my custom script?
eg:

const taskService = camForm.client.resource('task')
 taskService.get(camForm.taskId, function(err, task) {
 const processInstanceId = task.processInstanceId
}

in this code snip I have to access to camform to be able to get task.processInstanceId, but I dont know how to access “cam-script” directive in my custom module which is injected to embedded form as custom scrip.

Any idea would help a lot

@sebastian.stamm
@Ingo_Richtsmeier
do you have any idea ?

Anyone has any idea to fix the issue ?

Followup :
imaging you have a method to return businesskey like this :slight_smile:

       $scope.getProcessBusinessKey = function(){
            return new Promise(function (resolve, reject) {
                const taskService = camForm.client.resource('task')
                taskService.get(camForm.taskId, function(err, task) {
                    const processInstanceId = task.processInstanceId
                    fetch('/engine-rest/process-instance/' + processInstanceId)
                            .then(response => response.json())
                            .then(data => resolve(data.businessKey))
                            .catch(error => reject(error))
                })
            })
        }

this function should be written in a custom scrip and be called maybe as a Directive or Else in embeded form.
how can I get access to camunda variables in my custom script.?