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 Leenomeedo
#815031
Firstly I appreciate the support I found in this Fourm thank you to all who help and support me.
I followed the post here viewtopic.php?t=709602
viewtopic.php?t=709602
Not solved my problem
1- I have external database and connected to my process in dynaform I have id and name I just want when type the ID the name automatically fill .
2- I create the trigger bellow
$db='5095676575b30905c0bec46079475259';
$id=@@id;
$name=@@name;
$sql="SELECT BRANCH_CODE FROM CUSTOMERS WHERE ID_NO = @@id";
@@name = executeQuery($sql, $db);
put the trigger after Dynafourm
3- I test out the forum nothing happened
4- I repeated the same scenario but using PM database locally its working
What my mistake?
User avatar
By amosbatto
#815045
Have you tried using a Dependent Field query like this?
SELECT BRANCH_CODE, BRANCH_CODE FROM CUSTOMERS WHERE ID_NO = @@id
It is much easier than using a trigger.

If you really want to use a trigger, then your code should be something like this:
Code: Select all
@@name = '';
$db='5095676575b30905c0bec46079475259';
$id=@@id;
$sql="SELECT BRANCH_CODE FROM CUSTOMERS WHERE ID_NO = '$id'";
$aResult = executeQuery($sql, $db);
if (!empty($aResult)) {
    @@name = $aResult[1]['BRANCH_CODE'];
}
This will only work if this trigger is fired before the Dynaform. If you want @@id to be set by the same dynaform where you display the @@name, then you will have to use PMFRedirectToStep() to return to the Dynaform. See this example of redirection in triggers:
http://wiki.processmaker.com/3.0/Submit ... n_triggers
#815050
Yes I have used it but it was not working. I ts working when I used internal Database in Mysql DB (DM).
amosbatto wrote: Fri Jul 06, 2018 12:08 am Have you tried using a Dependent Field query like this?
SELECT BRANCH_CODE, BRANCH_CODE FROM CUSTOMERS WHERE ID_NO = @@id
It is much easier than using a trigger.

If you really want to use a trigger, then your code should be something like this:
Code: Select all
@@name = '';
$db='5095676575b30905c0bec46079475259';
$id=@@id;
$sql="SELECT BRANCH_CODE FROM CUSTOMERS WHERE ID_NO = '$id'";
$aResult = executeQuery($sql, $db);
if (!empty($aResult)) {
    @@name = $aResult[1]['BRANCH_CODE'];
}
This will only work if this trigger is fired before the Dynaform. If you want @@id to be set by the same dynaform where you display the @@name, then you will have to use PMFRedirectToStep() to return to the Dynaform. See this example of redirection in triggers:
http://wiki.processmaker.com/3.0/Submit ... n_triggers
User avatar
By amosbatto
#815057
Have you tried it without the dependent field relationship?
SELECT BRANCH_CODE, BRANCH_CODE FROM CUSTOMERS
If it doesn't work that way, then your database connection is bad or your field names are wrong.
#815059
I double checked and created a new MYSQL database and connected to processmaker then by using dependent fileds i typed (SELECT BRANCH_NAME FROM CUSTOMERS WHERE BRANCH_CODE=@id) I am relay confused find snapshot attached
amosbatto wrote: Fri Jul 06, 2018 12:08 am Have you tried using a Dependent Field query like this?
SELECT BRANCH_CODE, BRANCH_CODE FROM CUSTOMERS WHERE ID_NO = @@id
It is much easier than using a trigger.

If you really want to use a trigger, then your code should be something like this:
Code: Select all
@@name = '';
$db='5095676575b30905c0bec46079475259';
$id=@@id;
$sql="SELECT BRANCH_CODE FROM CUSTOMERS WHERE ID_NO = '$id'";
$aResult = executeQuery($sql, $db);
if (!empty($aResult)) {
    @@name = $aResult[1]['BRANCH_CODE'];
}
This will only work if this trigger is fired before the Dynaform. If you want @@id to be set by the same dynaform where you display the @@name, then you will have to use PMFRedirectToStep() to return to the Dynaform. See this example of redirection in triggers:
http://wiki.processmaker.com/3.0/Submit ... n_triggers
Attachments
(317.82 KiB) Downloaded 212 times
#815087
The only think I see is that your BRANCH_CODE field is an integer, so your query should be:
SELECT BRANCH_NAME FROM CUSTOMERS WHERE BRANCH_CODE=@#id

Check whether the ID of the field is spelled "id" and the field has a variable named "id".
amosbatto wrote:Have you tried it without the dependent field relationship?
SELECT BRANCH_CODE, BRANCH_CODE FROM CUSTOMERS
Can you answer this question?
#815094
Great You are exactly right its working now I appreciate your help thank you
amosbatto wrote: Tue Jul 10, 2018 2:32 am The only think I see is that your BRANCH_CODE field is an integer, so your query should be:
SELECT BRANCH_NAME FROM CUSTOMERS WHERE BRANCH_CODE=@#id

Check whether the ID of the field is spelled "id" and the field has a variable named "id".
amosbatto wrote:Have you tried it without the dependent field relationship?
SELECT BRANCH_CODE, BRANCH_CODE FROM CUSTOMERS
Can you answer this question?
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[…]