Share ideas, ask questions, and get feedback about developing for ProcessMaker
Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By mumpierrez
#16195
Hi people,

I just installed PM and I'm struggling with triggers and the @@SYS_NEXT_USER_TO_BE_ASSIGNED system variable.

First of all: Is @@SYS_NEXT_USER_TO_BE_ASSIGNED really a system variable? And I ask this because here (http://wiki.processmaker.com/index.php/ ... n_Triggers) you can't see it listed. Given the amount of references to @@SYS_NEXT_USER_TO_BE_ASSIGNED I'm assuming it exists.

I have 3 tasks and after the 1st one I move to the 2nd which has a simple dynaform which contains a Radio Button and based on its selection I want to set the @@SYS_NEXT_USER_TO_BE_ASSIGNED to the original issuer of the case (supposedly store in @@USER_LOGGED) or the only user to which task 3 is assigned.

I have added a trigger to the process and also added to task 2 under Steps Of -> Triggers -> Assign task -> Before Assignment, with no conditions

I have tested the SQL and it's returning the correct values.

Debug is not helping me at all. I don't see the trigger... I get the error saying @@SYS_NEXT_USER_TO_BE_ASSIGNED has no value or does not exist.

PLEASE HELP! Thanks!

The trigger is:

if (@@Action == 'Reject')
@@SYS_NEXT_USER_TO_BE_ASSIGNED = @@USER_LOGGED;
else
{
$aTasks = executeQuery("SELECT CON_ID FROM CONTENT WHERE CON_VALUE='Approve TS (RD)'");
$taskId = $aTasks[1]['CON_ID'];

//look up all the assigned users to the the task in the database
$aUsers = executeQuery("SELECT USR_UID FROM TASK_USER WHERE TAS_UID='$taskId' AND TU_TYPE='1'");

//get USR_UID of the RD which is the only user of the assigned to the 'Approve TS (RD)' task
@@SYS_NEXT_USER_TO_BE_ASSIGNED = $aUsers[1]['USR_UID'];
}
User avatar
By amosbatto
#16281
@@SYS_NEXT_USER_TO_BE_ASSIGNED is not a system variable. It only exists if you create it (in a trigger or in a DynaForm field named "SYS_NEXT_USER_TO_BE_ASSIGNED").

You need to fire the trigger in a task prior to the task which uses value based assignment for its designation rule.

If the trigger does not seem to be firing, try assigning your trigger to fire after the last step in the task instead of before assignment.

There are a couple trigger bugs in PM:
1. In certain cases the trigger didn't fire (especially after read-only dynaforms without a submit action)
2. Sometimes the trigger fires, but the debugger wasn't getting updated (especially at end of tasks)
I think that the first bug has been fixed in the latest version of PM, but I don't know about the debugger update problem.
By TingTingXie
#780135
Hi, there?

did you find your answer, cause i'm struggling at the same issue as you, and almost same code i used as you, not working now.

If you found some solutions in the end, could you let me know please, i do really need it urgently!
Thanks a lot!

Just a quick glare of my issue: i need some code to point it back to the first employee
Attachments
PM 1.png
Sample design
PM 1.png (8.64 KiB) Viewed 5378 times
User avatar
By liliana
#780143
Hi TingTingXie,

Well there is a simple way to do this, use the following code which will helps you to capture the user who starts the case. Use the @@FirstUser variable in value based assignment rule and also add it as a hidden variable in your Dynaform, this beacuase it is necessary to store the value of the variable during the execution of the process and while you are submitting your tasks until task 3, there you need to use a the evaluation routing rule
Code: Select all
if (!isset(@@FirstUser))
   @@FirstUser = @@USER_LOGGED;
Hope this helps you.

Regards,
By bwph67
#780191
I tried the @@firstuser=@@USERLOGGED. Sometimes it works and sometimes not. Looking at the APP_DATA field in the APPLICATION table it appears that sometimes the assignment is to firstuser and sometimes to FIRSTUSER. Thus sometimes a step fails when it can't find the right variable. I can't find anywhere I used the upper case version (although FLD_NAME in FIELDS is always upper case).
By TingTingXie
#780302
liliana wrote:Hi TingTingXie,

Well there is a simple way to do this, use the following code which will helps you to capture the user who starts the case. Use the @@FirstUser variable in value based assignment rule and also add it as a hidden variable in your Dynaform, this beacuase it is necessary to store the value of the variable during the execution of the process and while you are submitting your tasks until task 3, there you need to use a the evaluation routing rule
Code: Select all
if (!isset(@@FirstUser))
   @@FirstUser = @@USER_LOGGED;
Hope this helps you.

Regards,
Thank you for your reply, in the end i have found a solution: to use trigger after routing:
trigger will be similar like below, and it works, i get the idea from the enterprise sample process. Here the "repUseremail" is like a global variable which stored the first person's email address, and then it will flow through.
Attachments
negative response.PNG
trigger for negative response
negative response.PNG (5.16 KiB) Viewed 5359 times
By TingTingXie
#780303
bwph67 wrote:I tried the @@firstuser=@@USERLOGGED. Sometimes it works and sometimes not. Looking at the APP_DATA field in the APPLICATION table it appears that sometimes the assignment is to firstuser and sometimes to FIRSTUSER. Thus sometimes a step fails when it can't find the right variable. I can't find anywhere I used the upper case version (although FLD_NAME in FIELDS is always upper case).

Hi, there,

As i wrote below, please try to use trigger for your purpose, store the original user's email as a global variable and call it out once the response is negative.
Hopefully it will help you. :D

If you're looking to save big on your next online […]

If you're looking to save big on your next online […]

If you're looking to save big on your next online […]

Use the latest Freecash referral code "FC2507[…]