Page 1 of 1

Open a case and its dynaform from external application

Posted: Mon Jan 21, 2019 3:46 am
by nevermore
Hi,
I'm developing an ASP.NET web application to use processmaker's features on it.
I wanna to show the inbox of each user in my own ASP.NET web application and when user clicks on each inbox item, open its dynaform and submit it.

Now, I've displayed the list of TODO cases in my own application, but i do not know how can i open the dynaform of the cases in my own application.

What's the solution?

Thank you.

Re: Open a case and its dynaform from external application

Posted: Tue Jan 22, 2019 12:16 am
by amosbatto
To get the list of steps in a task, you can use:
Get Steps for Task: GET /project/{prj_uid}/activity/{act_uid}/steps

Then, to get the properties of the fields in a Dynaform, you can install my extraRest plugin and use:
Get Dynaform fields: GET extrarest/dynaform/{dyn_uid}

If you want to display the Dynaform inside an iframe, then you can use:
Get login session ID: GET extrarest/session-id

Re: Open a case and its dynaform from external application

Posted: Tue Jan 22, 2019 5:53 am
by nevermore
amosbatto wrote: Tue Jan 22, 2019 12:16 am To get the list of steps in a task, you can use:
Get Steps for Task: GET /project/{prj_uid}/activity/{act_uid}/steps

Then, to get the properties of the fields in a Dynaform, you can install my extraRest plugin and use:
Get Dynaform fields: GET extrarest/dynaform/{dyn_uid}

If you want to display the Dynaform inside an iframe, then you can use:
Get login session ID: GET extrarest/session-id
Thank you,
But i've got an error while uploading your plugin:
"Plugins
The file ExtraRest-1.9.tar doesn't contain class: ExtraRest"

What's the wrong ?

Re: Open a case and its dynaform from external application

Posted: Wed Jan 23, 2019 8:23 pm
by amosbatto
For some reason, MediaWiki seems to be screwing up .tar files. I uploaded it outside MediaWiki and have linked to that location in the documentation.
Try downloading it again:
https://www.pmusers.com/media/extraRest ... st-1.9.tar

Re: Open a case and its dynaform from external application

Posted: Sat Jan 26, 2019 1:23 am
by nevermore
amosbatto wrote: Wed Jan 23, 2019 8:23 pm For some reason, MediaWiki seems to be screwing up .tar files. I uploaded it outside MediaWiki and have linked to that location in the documentation.
Try downloading it again:
https://www.pmusers.com/media/extraRest ... st-1.9.tar
Thanks, the error was fixed, but when i upload and import the plugin, nothing happens and the plugin list shows nothing.!!!

Re: Open a case and its dynaform from external application

Posted: Mon Jan 28, 2019 8:33 am
by nevermore
I can not fix the issue, please suggest a solution :cry:

Re: Open a case and its dynaform from external application

Posted: Mon Jan 28, 2019 11:07 pm
by amosbatto
nevermore,
Let's do this the manual way. Decompress the .tar file. Then place the decompressed extraRest files in the following location on your ProcessMaker server:
workflow/engine/plugins/

Now you should have the following plugin registration file:
workflow/engine/plugins/extraRest.php
And the following plugin code file:
workflow/engine/plugins/extraRest/src/Services/Api/ExtraRest/Extra.php

Then, login as the "admin" user in ProcessMaker and go to Admin > Settings > Plugins > Plugin Manager and select the "extraRest" plugin in the list and click on the "Enable" button.

Now you should be able to call the extrarest endpoints.

Re: Open a case and its dynaform from external application

Posted: Tue Jan 29, 2019 2:46 am
by nevermore
Thanks,
When i click on PluginManager, the response is:

Notice: Only variables should be assigned by reference in C:\Bitnami\processmaker-3.3.0-2\apps\processmaker\htdocs\workflow\engine\plugins\extraRest.php on line 47
[{"id":1,"namespace":"extraRest","title":"extraRest Plugin\n(extraRest.php)","className":"extraRest","description":"Extra REST endpoints for ProcessMaker 3 by Amos Batto (amos@processmaker.com)","version":1.9,"setupPage":"","status_label":"Disabled","status":0,"setup":"0","sFile":"extraRest.php","sStatusFile":0}]

Re: Open a case and its dynaform from external application

Posted: Tue Jan 29, 2019 3:34 am
by amosbatto
Oh, I bet you are are using PHP 7.1 if you are using Bitnami, which is very strict about things like passing a reference.

Edit your workflow/engine/plugins/extraRest.php file and change this line from:
Code: Select all
$oPluginRegistry = &PMPluginRegistry::getSingleton();
To:
Code: Select all
$oPluginRegistry = PMPluginRegistry::getSingleton();
Now it should work.
Also to prevent other problems like that, edit your Bitnami/processmaker-3.XX-X/php/php.ini file and change the line from:
Code: Select all
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
To:
Code: Select all
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
Then, restart the Apache server or reboot.

Re: Open a case and its dynaform from external application

Posted: Tue Jan 29, 2019 3:56 am
by nevermore
Thanks a lot. It works fine.

Re: Open a case and its dynaform from external application

Posted: Mon Feb 04, 2019 2:51 am
by nevermore
Hello
I have a problem with the API:
When i call the 'http://localhost/api/1.0/workflow/extrarest/session-id' to get the SessionId, the response is:
'{"error":{"code":401,"message":"Unauthorized"}}'

What's wrong ?!
In addition, i'm logged in to ProcessMaker by GetToken.

Re: Open a case and its dynaform from external application

Posted: Mon Feb 04, 2019 7:40 pm
by amosbatto
nevermore wrote:Hello
I have a problem with the API:
When i call the 'http://localhost/api/1.0/workflow/extrarest/session-id' to get the SessionId, the response is:
'{"error":{"code":401,"message":"Unauthorized"}}'

What's wrong ?!
In addition, i'm logged in to ProcessMaker by GetToken.
You are probably not including the access token correctly in the header.
Post your code or post screenshots if using Postman or HttpRequestor in your web browser.

Re: Open a case and its dynaform from external application

Posted: Thu Mar 21, 2019 12:18 pm
by nevermore
Hi,
I have a new problem with session_id:

When i open browser with session_id, it responds this:

{"error":"You have lost your session and you have to login again.","success":true,"lostSession":true}

What's the problem?

Re: Open a case and its dynaform from external application

Posted: Thu Mar 21, 2019 9:28 pm
by amosbatto
The session ID expires after 24 minutes of inactivity.

If you are programming an external application, you will need to login again in REST and then call the extrarest/session-id endpoint again to get another session ID.

PS: You can increase the amount of time before it expires by going to Admin > Settings > System in ProcessMaker and increasing the size of Cookie Lifetime (Seconds).

Re: Open a case and its dynaform from external application

Posted: Fri Mar 22, 2019 3:32 am
by nevermore
Hello,
Thank you.
But i think this is not the main problem, because when i get token by '/workflow/oauth2/token' API and after that get session-id, i call other APIs immediately.

In addition when i call
'http://localhost:81/sysworkflow/en/neoc ... ction=sent' , it works fine,
but if i call
'http://localhost:81/sysworkflow/en/neoc ... ction=sent',
it responds the same error.

Re: Open a case and its dynaform from external application

Posted: Fri Mar 22, 2019 8:27 pm
by amosbatto
Did you append the session ID to the URL like this?
Code: Select all
http://localhost:81/sysworkflow/en/neoclassic/cases/cases_Open?APP_UID=2310038805c8e0cbb0e5d29066559382&DEL_INDEX=2&action=sent&sid=1234567890abcdef13456789
If .../cases/open?sid=1234567890abcdef1234567890 works, then use that.

Re: Open a case and its dynaform from external application

Posted: Sat Mar 23, 2019 10:07 am
by nevermore
Yes sure.

Re: Open a case and its dynaform from external application

Posted: Mon Mar 25, 2019 6:00 pm
by amosbatto
I looked at the code for workflow/engine/methods/cases/case_Open.php and I see that it is different from workflow/engine/methods/cases/open.php.

I have changed the documentation to use /cases/open
https://www.pmusers.com/index.php/Extra ... session-id

Re: Open a case and its dynaform from external application

Posted: Tue Feb 11, 2020 3:27 pm
by mrbm2007
I have same problem in
http://{domain_or_ip}/sys{workspace}/{lang}/{skin}/cases/cases_Step?TYPE=DYNAFORM&UID={dynaform_uid}&POSITION={position}&ACTION=EDIT&sid={session_id}
Reference from here: https://www.pmusers.com/index.php/ExtraRest_plugin#Get_login_session_ID:_GET_extrarest.2Fsession-id
I get access_token, then get extrarest/session-id, but whene send it to cases_Step with ...&sid={session_id} I get this:
{"error":"You have lost your session and you have to login again.","success":true,"lostSession":true}

Re: Open a case and its dynaform from external application

Posted: Fri Feb 21, 2020 4:58 am
by mrbm2007
I found the solution, I must use case_Open like this:
http://localhost:82/sysworkflow/en/neoclassic/cases/cases_Open?APP_UID=2471198445e3deb31146b45024134366&DEL_INDEX=1&sid=9942741045e4e32493627a2000185089
The case_Step can't be used directly!

Re: Open a case and its dynaform from external application

Posted: Sun Sep 19, 2021 8:25 am
by esraldi
Hi sir,

i I've succeeded load dynaform with session id, but when i tried to load the dynaform via iframe it couldn't,
https://myprocessmaker.co.id/sysworkflow/en/neoclassic/cases/cases_Open?APP_UID=44173914061444588379642010628945&DEL_INDEX=2&sid=238819494614728b6397751021883150

the error Refused to display 'https://myprocessmaker.co.id/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

thx