Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By devbhanu
#815807
Hi Team,
Please Help me out in the process.
two tables - Table A where the details of field1,field2,minamount,maxamount and approval1,approval2, approval3
Table B where based on field 1 field 2 and title of (approvals) retreive name and email

The user has to select the approval1 based on field1,field2,and amount and then form has to automatically
assign the next approvals assigned.

Assigned a trigger
Code: Select all
$query = "SELECT MIN_AMOUNT, MAX_AMOUNT, APPROVAL1, APPROVAL2, APPROVAL3, APPROVAL4 FROM  TABLE A JOIN TABLEB ON TITLE = APPRROVAL1 WHERE FIELD1 = '".@@field1."' AND FIELD2 = '".@@field2."' ";

$res = executeQuery($query);

if (is_array($res) && count($res) > 0) {
   if (( @@value > $res[1]['MIN_AMOUNT']) && (@@value < $res[1]['MAX_AMOUNT'])) {
        @@approval1 = $res[1]['APPROVAL1'];
        @@approval2 = $res[1]['APPROVAL2'];
        @@approval3 = $res[1]['APPROVAl3'];
        @@approval4 = $res[1]['APPROVAL4'];	
   }	
}
Don't know whether the code written is correct or not, kind of new to processmaker and PHP.

Assigned a sql statement in the dropdown (for assining approver) as SELECT EMAIL, EMPLOYEENAME FROM TABLEB WHERE FIELD1 = @@field1 AND FIELD2 = @@field2 AND TITLE = @@approval1
Here the value of the variable approval1 from the trigger.is this the correct way to pass the variable?

It is not possible to execute the query. Please contact your system administrator - error for the trigger.

Please guide me towards the process. Appreciate your Help! Thanks
User avatar
By amosbatto
#815811
You have an error in your SQL query. If you want to see the error message from MySQL, you need to add this line to your workflow/engine/config/env.ini file:
Code: Select all
debug = 1
Then, you will see the message from MySQL in the __ERROR__ variable in the debugger.
(Don't enable debug_sql if want to see the message.)

I suspect that the problem is that you aren't specifying the table in your fields.
Try this:
Code: Select all
$query = "SELECT A.MIN_AMOUNT, A.MAX_AMOUNT, A.APPROVAL1, A.APPROVAL2, A.APPROVAL3, A.APPROVAL4 FROM  TABLEA AS A 
   JOIN TABLEB AS B ON B.TITLE = A.APPRROVAL1 WHERE A.FIELD1 = '".@@field1."' AND A.FIELD2 = '".@@field2."' ";
The best way to figure out if a query is good to try it directly in MySQL (you can use phpMyAdmin which comes with ProcessMaker if you did a Bitnami install).





If you want to see the errIf you want to see the e
By devbhanu
#815835
Thanks amosbatto,
Specified table to fields, able to retrieve data.
Can you help me in the process. I am running into issues. I can only retrieve first row i think or maybe condition for checking the amount in between the value is not working.
Code: Select all
if (( @@value > $res[1]['MIN_AMOUNT']) && (@@value < $res[1]['MAX_AMOUNT'])) 
In a table I have data
Code: Select all
f1       f2      0    5,000        app1     app2
f1       f2     5,000   10,000      app1      app2    app3
The value or title of app1 is working below 5000. Not able get the value of app1 when the value is between 5000 and 10,000.

And how to loop the task based on the number of approvals.If app1 approved the case ,the task assigned to next approval app2 and so on.

Thanks for the Help.
User avatar
By amosbatto
#815859
You need to change all your numbers from 5,000 to 5000 in your database because commas are not valid numbers in PHP. Then you need to convert from strings to integers when doing your comparison:
Code: Select all
if (( @%value > (int) $res[1]['MIN_AMOUNT']) && (@%value <  (int) $res[1]['MAX_AMOUNT'])) 
If you want to be able to repeat the same task a variable number of times, see Repeating a Task with a Loop-Around. You can also use a task with a parallel marker, which is simpler.

The problem with both approaches is that that each new user assigned to the task will overwrite the data entered by the previous user, because the same variable is used for each field in the Dynaforms. If you need the user to fill out a Dynaform in the repeating task, then you will need to save the data to a grid or a PM Table. Here is an example:
viewtopic.php?f=41&t=710262&p=789936#p789936

It is much easier to not using repeating tasks, and create different dynaforms for each of your approval tasks, so the data doesn't get overwritten, like this:
variableNumberApprovalProcess.png
variableNumberApprovalProcess.png (15.81 KiB) Viewed 3133 times
You can use conditions in your routing rules like this to skip approval tasks:
RoutingRulesApproval3.png
RoutingRulesApproval3.png (23.07 KiB) Viewed 3133 times
Attachments
(68.55 KiB) Downloaded 236 times
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]