Share ideas, ask questions, and get feedback about developing for ProcessMaker

Moderators: ArturoRobles, ArturoRobles

Forum rules: Please post new questions under "Developing processes & programming" for ProcessMaker 2 or 3.
By blackbird
I'm new in Processmaker 3.1.

I have a dynaform with some fields. Suppose, a tour plan.
Code: Select all
for A,
---Start Date of Tour---       --- Last Date or Tour---   ---Destination----

for B,
---Start Date of Tour---       --- Last Date or Tour---   ---Destination----

Submit Plan
But A and B values will be different. Now when planner will submit the button then A plan will go to A and B plan will go to B. How can I capture the User A or B with trigger?
By mishika

To achieve your requirement follow the steps:
* Create a Grid (ID = gridVar001) in your dynaform with the fields:
    User(ID = user) Start Date (ID = start_date) End Date (ID = end_date) Destination (ID = dest)
* You can get all the users in the User dropdown field in this grid using the query:
Code: Select all
* Write a trigger to be fired after the dynaform:
Code: Select all
$grid_data = @=gridVar001;
$count = count(@=gridVar001);
for($i = 1; $i <= $count; $i++){
	$user = $grid_data[$i]['user'];
	@@user = $grid_data[$i]['user_label'];
	@@s1date = $grid_data[$i]['start_date'];
	@@e1date = $grid_data[$i]['end_date'];
	@@dest11 = $grid_data[$i]['dest'];
	$userdata = executeQuery($query);
	@@email = $userdata[1]['USR_EMAIL'];
	@@return = PMFSendMessage(@@APPLICATION, "sender's_email", @@email, "", "", "Plan", "out.html",array(''), array(''), TRUE, 0, "");
* To capture the user, a for loop is used which gets the user details turn by turn from the grid and fetches their corresponding email id from USERS table
* All user details are stored in variables so as to use them in the email template:
Code: Select all
Hello @=user,
The trip plan as decided by the planner is:
Start Date:@=s1date
End Date:@=e1date
Thank you
* On getting all the details an email is sent to the particular user.

Feel free to revert back in case of any queries.
Hope this helps.

By blackbird
Thanks for your reply.

But I am sharing some more issues with this.

Planner will plan for a year. So, when planner will submit the dynaform of a year, then The planner dynaform has two task. 1. Pick the current month. He will compare the Current Month with dynaform current month value, then he will sent the current month tour plan to the users/bosses. But he will submit a total year plan. From there the recent month's plan will go to users.

2. After checking the current month, he will sent the tour date and destination to users. One user will not be able to see others tour plan. I think you gave me the 2nd issues answer. If I don't want to use drop down then what will be the progress. I think it is possible to do without drop down, because their variables are different. But don't know how to implement this. :shock:
One more things, I don't want to give email to users. I will give them another form with their Date and Destination time. They will be able to Accept, Reject it.
If you help me it will be great.
By mishika

Your requirement regarding assigning a dynaform to the user can be completed by the following way:
1. Create a task just after the task in which you have the dynaform to enter the plan. This task will have another dynaform with the Date and Destination of plan and the user will Accept/Reject it.
2. This second task will be having a Value Based Assignment Rule.
3. You can surely get the users entered in the text field but getting the users in a dropdown will be more helpful because, if you get the users entered manually, you will need to enter the exact name as in the database, because it will be used to fetch USR_UID from the USERS table to be assigned as the value for the assignment of next task.
4. You will also need to use a gateway after the second task which will repeatedly call the same task until all the users who have been assigned a plan go through that task.

You can refer to the attached image(plan1) to get the idea of the flow of process described above.

Regarding the first issue, in which you are getting the plan entered for the entire year, I have a few doubts in its understanding:
What is the format for the yearly plan that you are getting entered in the dynaform?
Will you be saving the entire year's plan, while sending the current month's plan to the next user?
plan1.png (43.9 KiB) Viewed 4169 times
By blackbird
Thanks again for your answer.
I am using grid now by your suggestion.

This is my Tour Plan Flow. Simple.
plan1.PNG (17.07 KiB) Viewed 4163 times
And this is my Dynaform in the last attachment .

Now I will Submit my Plan to users. User has the form with just Date and Destination properties. How a user will catch these information by the login information? Suppose, CEO will get his information, CFO will get his information and so on. CEO will not see CFO information and vise versa. This is my first target.

Second Target is, now February. When he will submit the button, he will submit only the February Data

Again Thanks to help me. Now I think you are clear and will be easy to help me.
plan.PNG (23.2 KiB) Viewed 4163 times
By mishika

I would suggest that instead of taking 12 grids, one for each month, you should take text field which should be read-only and will be auto filled with the current month using a trigger.
Taking 12 grids will increase the processing time of your process and reduce its efficiency because, for checking the current month before routing to the next task, we will have to use a switch case with 12 cases and it will make the process really slow.

To achieve your first target i.e., plan should reach the corresponding users, you can do the following:
1. If you want the task for different users to run in parallel, you should fix the maximum number of parallel tasks before designing the process.
2. In the task Tour Plan create a dynaform similar to yours but with only one grid and one text field(for month).
3. In the process after the task Tour Plan, use an Inclusive Gateway which will point to different user tasks.(refer the attached image)
4. All the tasks attached to this gateway will be having Value Based Assignment. These tasks will work in parallel and will next go to a same or different task according to your requirement.
5. Also, you should save the values of the grid into database(a PM Table). A PM Table say PMT_PLAN which will have an auto incrementing ID as the primary key and other fields as: USER, DATE, DEST. This will reduce the redundancy that will be caused in the parallel tasks.
6. Now, create the following trigger :
Code: Select all
$aUsers = @=gridVar001;
@%noMembers = count($aUsers);
if (@%noMembers >= 1)
   @@userForTask1 = $aUsers[1]['user'];
if (@%noMembers >= 2)
   @@userForTask2 = $aUsers[2]['user'];
if (@%noMembers >= 3)
   @@userForTask3 = $aUsers[3]['user'];
if (@%noMembers >= 4)
   @@userForTask4 = $aUsers[4]['user'];
for($i = 1; $i <= @%noMembers; $i++){
	$query = "INSERT INTO PMT_PLAN (USER , DATE, DEST) VALUES ('$aUsers[$i]['user']','$aUsers[$i]['pdate']','$aUsers[$i]['dest']')";
	$result = executeQuery($query);
The trigger will get the USR_UID of all the users who have been assigned a plan and store them in variables so as be used for the value based assignment of the next task.
7. For the next set of tasks(parallel tasks) create a dynaform and a trigger which will fetch the details of the plan for the logged in user and assign it to the fields in the dynaform.
8. The trigger and dynaform can now be same for all the tasks.
Trigger to be used here can be as follows:
Code: Select all
$result = executeQuery($query);
@@user_date = $result[1]['DATE'];
@@user_dest = $result[1]['DEST'];
where @@user_date and @@user_dest are the variables for fields in the dynaform for the user task.

Please execute the above codes and let me know if this serves your requirements.

Hope this helps.

Best Regards
plan2.png (25.92 KiB) Viewed 4159 times
By blackbird

I need 12 grid because I will plan for 1 year at a time.

It's not possible to do with on User form? I will assign various users in this DynaForm. When one user will log in, I will catch his Loggin Information and I will search his information.

In user Dynaform, I will just Show the searched result (User Name, Date and Tour Destination.)
I am thinking in this and try to implement like this.
By mishika

You can assign multiple users to the task using Cyclical Assignment Rule, but during assignment it will be assigned only to a single user. And therefore, in a single case only that particular user will be able to access that task.

For more details on Assignment rules you can refer the link:

If you have a requirement that, you need multiple users to access the same task in the same case, you will have to use either of the two ways:
1. keep the users task in a loop(refer image)
plan1.png (43.9 KiB) Viewed 4154 times
2. create multiple parallel tasks(refer image)
plan2.png (25.92 KiB) Viewed 4154 times
Hope this helps

Best Regards
REST API Question

I am currently looking at developing a portlet for[…]

Everybody wants to be famous, but nobody wants to […]

Hi, I attached a sample config file, Please check […]

Error clicking on Participated

Hi, I attached a sample config file, Please check […]