Page 1 of 1

[SOLVED] Is this possible to pass argument to triggers?

Posted: Wed Jul 24, 2019 1:04 pm
by ehsanv
Hi,
I want to pass user input(text field) to a trigger to check with database and see if the user input is in database or not and return the related user input values.
But I can't find any related topic about it.
I also tried to set a case variable for trigger to use, but setting variables need PM_CASES permission which i can't have it for operator users.
Please help me.

Thanks in advance

Re: Is this possible to pass argument to triggers?

Posted: Wed Jul 24, 2019 9:08 pm
by amosbatto
The PROCESSMAKER_OPERATOR role has the PM_CASES permission. An Operator can't see any cases without the PM_CASES permission. Are you thinking of another permission?

How are you executing your trigger? If you are using REST or the executeTrigger() web service, ProcessMaker will check whether the logged-in user is assigned to the task (indicated by the delegation index) in the case.

ProcessMaker doesn't provide a way to pass arguments to a trigger. What you have to do is set variables in the case and then have your trigger code use those case variables. Then you can unset those variables in the case if you don't want them to remain.

If you install the extraRest plugin, there is a REST endpoint that allows you to set variables, execute the trigger and then unset the variables in one operation.
See:
PUT http://{domain-or-ip}/api/1.0/{workspace}/extrarest/case/{app_uid}/execute-trigger/{tri_uid}

That endpoint also allows you to get around the security restrictions that are probably causing your problem.

Re: Is this possible to pass argument to triggers?

Posted: Thu Jul 25, 2019 5:04 am
by ehsanv
I'm using javascript and REST API. I used Value Based Assigment for tasks and the value is @@USER_LOGGED because i wanted the user who started the case do the whole case.
About PM_CASES you are right! But i don't know why I can't set variables, this is my code:
Code: Select all
$.ajax({url:host+'/api/1.0/'+ws+'/cases/'+caseID+'/variable', data:{'strBuffer':this.value}, type:'PUT'});
My case variable name is strBuffer and i wanted to set it my value and used it in trigger.

finally about extraRest, I used it and worked! Thanks!

Re: [SOLVED] Is this possible to pass argument to triggers?

Posted: Thu Jul 25, 2019 9:38 pm
by amosbatto
You need to set the access token in the header. See "Example 2" at this page:
https://wiki.processmaker.com/3.2/JavaS ... ing_jQuery