Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By erdalayan
#823717
Hi,

we are working on a new workflow process and I was wondering if it is possible to get user data via REST API from LDAP. I have watched several tutorials and latest webinar on that topic but it did not seem very simple for me. Can you please recommend me basic documentation/tutorial to have a look at?
Best...

Erdal Ayan, M.A.-M.Sc.
#823718
ProcessMaker doesn't provide a REST endpoint to access LDAP. If the user has already been imported from LDAP into ProcessMaker, then you will see the user in the list returned by this REST endpoint:
GET /api/1.0/{workspace}/users?filter={filter}&start={start}&limit={limit}& status={status}

If you want a REST endpoint to access LDAP, there are a number of external programs that provide that. Google it.

As for a REST tutorial, Here is one for jQuery:
https://spring.io/guides/gs/consuming-rest-jquery/

What language are you using?
#823735
Dear Amosbatto,

thank you for your quick response. I have checked the documents now.
We have not decided on the language but I guess we will simply use JavaScript for REST API integration.
Best..

Erdal Ayan, M.A.-M.Sc.
#824081
Dear Amos Batto,

thank you for your responses. I have checked the documentation you sent but it is really confusing for me to use them. I have a very simple workflow and I have to get the user list from Ldap via rest api but it is still very complicated for me. Where do I have to create the user list? Inside the dynaform or in the admin panel? Can you recommend me a very simple solution?Image
Image
Attachments
Selection_411.png
Selection_411.png (12.46 KiB) Viewed 16256 times
Selection_410.png
Selection_410.png (25.99 KiB) Viewed 16256 times
#824087
I though that you wanted a generic REST endpoint to access LDAP, but this question indicates that you just want the standard LDAP user import which ProcessMaker provides.

If you want to use LDAP users in Manual Assignment (as you show in your screen shot), then you need to go to ADMIN > Users > Authentication Sources and import your LDAP users.
See: https://wiki.processmaker.com/3.0/Exter ... entication

After you import your users from LDAP, then you can access them using the standard GET /users REST endpoint, but you probably don't need that.
#824101
Dear amosbatto,

thank you so much. Ldap integration seems to work fine for me. I can not import the users into my processmaker.
I was just wondering if i have to use "GET /users REST endpoint" to get the user list and include them in the text field as you can see in the screenshot below. What is the procedure for that? I have actually created a variable called "participantName" (see the second screenshot) to get the user that I important but I do not know how I will call them.
Selection_415.png
Selection_415.png (4.88 KiB) Viewed 16241 times

Selection_416.png
Selection_416.png (79.52 KiB) Viewed 16241 times
Another thing is to decide on the assignment rules, which one should I use to get the users that I imported from ldap (see screenshot below)?
Selection_417.png
Selection_417.png (62.6 KiB) Viewed 16241 times
Best...
Erdal Ayan
#824109
erdalayan wrote: Wed Apr 24, 2019 11:29 am I was just wondering if i have to use "GET /users REST endpoint" to get the user list and include them in the text field as you can see in the screenshot below.
If you do it that way, you will set a default value in the variable when the variable is first created in your process.
If that is what you want, then you can use this SQL query:
SELECT USR_USERNAME, USR_USERNAME FROM USERS

Then the variable will be set to the first record returned by the SQL query.

If you want to be able to select a user from a dropdown box in a Dynaform, then in the Dynaform Editor add a dropdown box. In the dropdown's sql property you can use this query:
SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME, ' (', USR_USERNAME, ')') FROM USERS
#824110
erdalayan wrote: Wed Apr 24, 2019 11:29 am Another thing is to decide on the assignment rules, which one should I use to get the users that I imported from ldap (see screenshot below)?
You can use any of the Assignment rules with the LDAP users that you imported. The LDAP users should appear in the list of available users for all the assignment rules.
#824117
amosbatto wrote: Wed Apr 24, 2019 11:29 pm
erdalayan wrote: Wed Apr 24, 2019 11:29 am I was just wondering if i have to use "GET /users REST endpoint" to get the user list and include them in the text field as you can see in the screenshot below.
If you do it that way, you will set a default value in the variable when the variable is first created in your process.
If that is what you want, then you can use this SQL query:
SELECT USR_USERNAME, USR_USERNAME FROM USERS

Then the variable will be set to the first record returned by the SQL query.

If you want to be able to select a user from a dropdown box in a Dynaform, then in the Dynaform Editor add a dropdown box. In the dropdown's sql property you can use this query:
SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME, ' (', USR_USERNAME, ')') FROM USERS
Dear Amosbatto,

Thank you so much.
The second option worked fine for my case. I was wondering if it is possible to limit and list the user according to the departments they belong to.

Best...
Erdal Ayan, M.A.-M.Sc.
#824120
Dear Amosbatto,

I have recently created two dropdowns. One for the departments and the other for employees. I can get the department list from pm via "SELECT CON_ID, CON_VALUE FROM CONTENT WHERE CON_CATEGORY='DEPO_TITLE' ORDER BY CON_VALUE" and my variable and id are selectDepartment in the first dropdown. For the second dropdown, I want to get the employee from the same department where the employee is registered. I used your sql ("SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME) WHERE DEP_UID=@@selectDepartment" for this purpose but it is not functioning. Did I miss sth in the sql or do I have to add sth different in the properties of the dropdowns.
Selection_418.png
Selection_418.png (12.45 KiB) Viewed 16220 times
Best...
Erdal Ayan
#824122
erdalayan wrote: Thu Apr 25, 2019 8:49 am Dear Amosbatto,

I have recently created two dropdowns. One for the departments and the other for employees. I can get the department list from pm via "SELECT CON_ID, CON_VALUE FROM CONTENT WHERE CON_CATEGORY='DEPO_TITLE' ORDER BY CON_VALUE" and my variable and id are selectDepartment in the first dropdown. For the second dropdown, I want to get the employee from the same department where the employee is registered. I used your sql ("SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME) WHERE DEP_UID=@@selectDepartment" for this purpose but it is not functioning. Did I miss sth in the sql or do I have to add sth different in the properties of the dropdowns.

Selection_418.png

Best...
Erdal Ayan
Dear Amosbatto,
I have solved this problem when I just adjusted sql code a bit ("SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME, ' ') FROM USERS WHERE DEP_UID=@@selectDpt". Now the employee can be selected automatically when the user chooses the department.
Selection_419.png
Selection_419.png (9.27 KiB) Viewed 16217 times
Thanks..
#825094
Dear Amosbatto,

I wanted to clarify the Rest API issue again. We have an ldap server and two rest apis improved to get data from the ldap server. We want to take data directly via the improved rest apis (not via connecting directly to ldap servers) and integrate it to our processmaker. Do you know anything about how to do this? I think this is going to be trigger which will be active when the first user enters into the system. Do you have any other recommendation for that?
Best...
Erdal Ayan
#825095
Hi again,

My workflow is like the following shot. And Actually, i want to get access to external rest api and take the profile data of the first user (login data(username,password), email, department name, etc) and the second user (login data(username password), department, name and surname). I have got dropdowns for the second user. How can I create a script to solve this problem?

Image

Best...
Erdal Ayan
Attachments
Selection_648.png
Selection_648.png (27.32 KiB) Viewed 15600 times
#825108
erdalayan wrote: Tue Jun 25, 2019 9:53 am My workflow is like the following shot. And Actually, i want to get access to external rest api and take the profile data of the first user (login data(username,password), email, department name, etc) and the second user (login data(username password), department, name and surname). I have got dropdowns for the second user. How can I create a script to solve this problem?
I don't think that you need to use REST.
You can use the userInfo() function in a trigger to get information on a particular user (as long as you have imported that user with LDAP).

For example:
Code: Select all
//if variable not empty, then get user info
if (@@selectUser) {
    $aInfo = userInfo(@@selectUser);
    @@name = $aInfo['firstname'];
    @@surname = $aInfo['lastname'];
    @@username = $aInfo['username'];
    @@department = $aInfo['department'] ? $aInfo['departmentname']  : ''; 
}

Where selectUser is the variable associated with the dropdown box where the user was selected. Remember that the ID of the user needs to be the value in the @@selectUser variable, so the SQL to populate the dropdown box associated with the selectUser variable should return the ID of the user as the first field like this:
SELECT USR_UID, CONCAT(USR_FIRSTNAME, ' ', USR_LASTNAME) ...

There is no way to get the password of a user in clear text, because passwords are stored as hashes (MD5, SHA256, etc.) for security reasons. Why do you need the password?
#825120
Dear Amosbatto,

I had already done what you have recommended and I can import the users via basic LDAP integration. This works very fine. There is no problem with that. But my boss is not willing to use direct ldap but rest api they created already. I have two fields in my form as you may see below. The first one for the firt user and the second one is for the second user. The data of the first and second users will be taken from rest api via a call. Actually I have found a wiki entry (See:<https://wiki.processmaker.com/3.0/Calli ... _Endpoints>) about calling external rest api via php curl library, I guess this may work, I will try it today but my problem is that "how can I use/transfer the data to the dynaform?" I am not sure if a script task with an auto-fill trigger, which is set before the exact process, work?


I do not need username and password since another authentication method will be planned for the login process as I was told yesterday.
Selection_650.png
Selection_650.png (9.39 KiB) Viewed 15585 times
Selection_651.png
Selection_651.png (9.92 KiB) Viewed 15585 times
Best..
Erdal Ayan
#825125
Dear Amosbatto,

I managed to connect rest api via php (curl: <https://wiki.processmaker.com/3.0/Calli ... _Endpoints>) but still I do not actually know how I can take the data into my dynaform for the two user spaces that I sent you above.
Can I still use autofill codes that you sent in the earlier post? Or do I have to create another trigger for that?
Best..
Erdal Ayan
#825144
erdalayan wrote:I managed to connect rest api via php (curl: <https://wiki.processmaker.com/3.0/Calli ... _Endpoints>) but still I do not actually know how I can take the data into my dynaform for the two user spaces that I sent you above.
Can I still use autofill codes that you sent in the earlier post? Or do I have to create another trigger for that?
In the same trigger where you call the REST API, you can set the variables used by the fields in your Dynaform. For example:
Code: Select all
//call the REST endpoint here and place the user info in an array named $aUserInfo
@@name = $aUserInfo['firstname'];
@@surname $aUserInfo['lastname'];
Set the trigger to fire before the Dynaform so the variables will be set when the Dynaform is loaded.

If you need to populate the list of options in a dropbox, see:
https://wiki.processmaker.com/3.0/DynaF ... Datasource
#825173
Dear Amosbatto,

thank you for your information. I have tried it but it does not fill it out. They are in the same trigger. See:

[...]
if ($statusCode != 200) {
if (isset ($aUsers) and isset($aUsers->error))
print "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
else
print "Error: HTTP status code: $statusCode\n";
}
else {
foreach ($aUsers as $oUser) {
if ($oUser->usr_status == "ACTIVE") {
print "{$oUser->usr_firstname} {$oUser->usr_lastname} ({$oUser->usr_username})\n";
}
}
}

@@firstname = $aUserInfo['firstname'];
@@surname $aUserInfo['lastname'];

Best...
#825174
Hi,

I can not populate it. Do I need an "if" statement like below:
Code: Select all
if ($statusCode != 200) {
   if (isset ($aUsers) and isset($aUsers->error))
      print "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
   else
      print "Error: HTTP status code: $statusCode\n";
}
else {
   foreach ($aUsers as $oUser) {
      if ($oUser->usr_status == "ACTIVE") {
         print "{$oUser->usr_firstname} {$oUser->usr_lastname} ({$oUser->usr_username})\n";
		  }
   }
	if (empty(@@firstName)) {
   $aUser = aUserInfo(@@USER_LOGGED);
	@@firstName = $aUserInfo['given_name'];
	@@surname = $aUserInfo['surname'];
	@@emailAdress = $aUserInfo['email'];
	@@department = $aUserInfo['roles'];
	@@position = $aUserInfo['roles'];

}

}
#825190
If you are doing this in a trigger, you will never see the output from those print statements unless you call die(). I recommend turning on Debug Mode, and then using this code:
Code: Select all
if ($statusCode != 200) {
   if (isset ($aUsers) and isset($aUsers->error))
      @@error =  "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
   else
      @@error = "Error: HTTP status code: $statusCode\n";
}
else {
   if (empty($aUsers)) {
       @@error = "No users returned";
   }
   else {
	@@firstName = $aUsers[0]->usr_firstname;	
        @@surname = $aUsers[0]->usr_lastname;
	@@emailAdress = $aUsers[0]->usr_address;
	@@department = $aUsers[0]->usr_department;
	@@position = $aUsers[0]->usr_role;
   }
}
If you can't figure it out, post all your code. I'm not even sure what endpoint you are calling, so I don't know if I'm accessing the information correctly.
#825215
Hi,
thank you for the hints. I have tried it but it is still not responding and filling out the form spaces.
Here are the codes for the trigger:
Code: Select all
$username = 'XXXX';
$password = 'XXXXX';
$ch = curl_init("XXXXXX");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);

$oRet = json_decode(curl_exec($ch));
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$pmServer = "XXXXXX"; //set to your ProcessMaker address

$ch = curl_init($pmServer . "XXXXXX");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$aUsers = json_decode(curl_exec($ch));
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($statusCode != 200) {
   if (isset ($aUsers) and isset($aUsers->error))
      @@error =  "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
   else
      @@error = "Error: HTTP status code: $statusCode\n";
}
else {
   if (empty($aUsers)) {
       @@error = "No users returned";
   }
   else {
	@@firstName = $aUsers[0]->usr_given_name;	
    @@surname = $aUsers[0]->usr_surname;
	@@emailAdress = $aUsers[0]->usr_email;
	@@department = $aUsers[0]->usr_department_display_name;
	@@position = $aUsers[0]->usr_role;
   }
}
#825226
You need to debug it.

If you are using a trigger, then do this to see what is being returned:
Code: Select all
$username = 'XXXX';
$password = 'XXXXX';
$ch = curl_init("XXXXXX");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);

$oRet = json_decode(curl_exec($ch));
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$pmServer = "XXXXXX"; //set to your ProcessMaker address

$ch = curl_init($pmServer . "XXXXXX");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch)
print "<pre>"; var_dump($result); //die();
$aUsers = json_decode($result);
var_dump($result); //die();
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
var_dump($statusCode); die();
curl_close($ch);

if ($statusCode != 200) {
   if (isset ($aUsers) and isset($aUsers->error))
      @@error =  "Error code: {$aUsers->error->code}\nMessage: {$aUsers->error->message}\n";
   else
      @@error = "Error: HTTP status code: $statusCode\n";
}
else {
   if (empty($aUsers)) {
       @@error = "No users returned";
   }
   else {
	@@firstName = $aUsers[0]->usr_given_name;	
    @@surname = $aUsers[0]->usr_surname;
	@@emailAdress = $aUsers[0]->usr_email;
	@@department = $aUsers[0]->usr_department_display_name;
	@@position = $aUsers[0]->usr_role;
   }
}
If nothing appears on the screen, then uncomment the die() statements until you find the last part of the code that executes. Then you know that the next line is what is causing the problem.
#825227
Dear Amosbatto,

I have tried as you mentioned but nothing appears in the form. I know I can get access to rest but I can not get the data from the rest.

Let me mention that I imported the user from ldap via basic ldap authentication method but I noticed that I can not get into processmaker via the imported profiles password and so I changed the authentication of the user to Processmaker(Mysql) as you may see below. I do not know if it affects the trigger? Because from the login the imported user should be defined as ldap authenticated one... I am not sure of this actually...
Selection_658.png
Selection_658.png (8.32 KiB) Viewed 15348 times
Best ...
Erdal Ayan
#825231
Are you using a custom REST endpoint from another service or one of the standard ProcessMaker REST endpoints?

Does Debug Mode show you anything in the __ERROR__ variable (which is only created if there is an error)?

You need to comment out bits of code in your trigger and add more print and die statements until you figure out exactly what is causing the problem. These are the basic steps to debugging your code and figuring out what is the problem. If nothing is printing on the screen, then you might have a syntax error in your code. Keep commenting out more and more code until you find it.
#825248
Dear Amosbatto,

thank you so much, I have recently solved the problem of rest api integration for taking data for the first fields. Now I will try if I can take the data for dropdown menus.

Best...
Erdal Ayan
#826177
Dear Amosbatto,

I could not manage to populate drop down via rest api... :( I get only some irrelevant data from the rest via the following codes:
Code: Select all
if ($result === false) {
    $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    @@error = "Error: HTTP status code: $statusCode\n";
} else {
    $aUsers = json_decode($result, true);
    if (empty($aUsers)) {
        @@error = "No users returned";
    }
    else {
        @=selectDpt = [];
        @=userList = [];
        $run = -1;
        foreach ( $aUsers as $user ) {
            $run += 1;
            @=selectDpt[] = array($user['department_dn'], $user['department_display_name']);
            @=userList[] = array(($run+1) . '', $user['given_name'] . $user['surname']);

        }
        var_dump(@@selectDpt);
    }
}
Output: Image
Attachments
Selection_748.png
Selection_748.png (11.23 KiB) Viewed 14986 times
#826189
It's impossible to debug without knowing the structure of your result.

Change your code to this:
Code: Select all
    $aUsers = json_decode($result, true);
    print "<pre>"; var_dump($aUsers); die;
Then, run the case and post the output on your screen.

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]