Add URL TO a form

1
0
-1

Good morning ! so I have a process with two human tasks and added two external Forms to em using external URL option. Everything work fine in the portal . My goal is when I start the process outside the portal, I will be able to access the form using a URL containing that specific processeId and taskId, so how to build that URL , how to add it to the form , and what is the format of the Form URL ?

1 answer

1
+1
-1

In Firefox, you can find the url of the form by opening the frame in the portal. All you have to do is right-click on the form in portal and select "This Frame" > "Open frame in new tab". I think there's an extension in Chrome that lets you do the same.
In I understand correctly, you would use that form url in an iframe on your external website, is that right?

You could also only use the API to submit the task, but beware of the fact that a task might not be assigned to the user and you might get an error. To correct this, you would need an assign button in your external form and an execute one. You can find these urls here: "https://documentation.bonitasoft.com/bonita/7.10/bpm-api". To assign, you need to pass assigned_id to the json payload of the request and to execute, change the state to completed through the json payload.

Comments

Submitted by fatma.ghorbel_1... on Tue, 05/19/2020 - 13:45

I tried it and get "http://localhost:port/bonita/form?displayConfirmation=false&id=160220"

yeah I want to be able to open the form with URL , outside the portal , after starting a case with an external form using "/bonita/API/bpm/process/processId/instantiation " , ii want to be redirected to the form of the task of that new Case , can I use that URL "http://localhost:port/bonita/form?displayConfirmation=false&id=160220" ?

Submitted by dumitru.corini_... on Tue, 05/19/2020 - 17:35

Ok, I understand your use case better now. When you instantiate a new process, the new task is not started instantly, you would need to find the new task that was created after you start the process. To do this, what you would do is make a loop that will do an API request to get the tasks associated with the processId (/API/bpm/activity?f=processId='The process id'), until you get at least one. The processId can be found in the response from the instantiation of the process.
After you find at least 1 task that was created by the process, you should have the taskId in the response. After that, you can use it to display the task (I think by default it is something like http://`Host`:`Port`/bonita/portal/resource/taskInstance/`ProcessName`/`ProcessVersion`/`TaskName`/content/?id=`TaskId`&displayConfirmation=false).
Is this the use case that you want to cover?

Just for your information, I don't know where the "http://localhost:port/bonita/form?displayConfirmation=false&id=160220" would come from, what did you do to find that url?

Submitted by fatma.ghorbel_1... on Tue, 05/19/2020 - 19:22

well what I ave tried to do after making the post request Of /instantiation , I sent another request using this URL "/bonita/API/bpm/userTask?c=2&p=0&f=caseId={caseId}" but its getting just one task (the first one of the process) and I made e redirection to thee URL form http://localhost:port/bonita/form?displayConfirmation=false&id=160220" after retrieving the taskId from the previous request response , and then when I try to submit the first form of that task , I don't know how to go to the next task "I tried "/bonita/API/bpm/userTask?c=2&p=0&f=caseId={caseId}" but it gives me the same Task and the same taskId that I'm trying to execute , not the next one , any solution ?

Submitted by dumitru.corini_... on Tue, 05/19/2020 - 19:41

Could you try adding a second filter to that request that filters by state ( &f=state=ready )?
I'm also asking myself if it might be a cache problem.

Submitted by fatma.ghorbel_1... on Tue, 05/19/2020 - 20:07

yess I did and its getting all the ready tasks , and then I added e filter for caseId , its showing an array with the ready tasks in the portal

Submitted by dumitru.corini_... on Tue, 05/19/2020 - 20:26

I don't know how to delete messages on this forum, I'll probably ask someone later on how to do it.
Just for me to understand "/bonita/API/bpm/userTask?c=2&p=0&f=caseId={caseId}&f=state=ready", still gives you the first task and doesn't give you the second task in the process? What happens if you call the same API after 5-10 seconds?

Submitted by fatma.ghorbel_1... on Tue, 05/19/2020 - 21:14

No it gives me the list of the tasks !

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 03:26

"http://localhost:port/bonita/form?displayConfirmation=false&id=160220" get it when I did right-click on the form in portal and select "This Frame" > "Open frame in new tab", isn't that url im gonna use to show the form?

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 08:28

Yes, that should be the url that you use. Also, I don't know if you can search a task through the userTask API, I would try using the humanTask API.

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 11:16

My goal is to assure that i have a navigation between the two external forms that belong to my 2 human task, but l dont want it through the Portal, but through my frontend app thats why I needed the urls and the other stuff.

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 11:23

What about the form API, when can i use it "/form/mapping "? Can you explain it for me?

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 11:42

I understand that you want to make a transition between the 2 human tasks, and if I understood you correctly, you seem to have a problem with getting the id of the 2nd task after you complete the 1st one. Am I correct?
Do you also have a problem with redirection to the portal after you complete the 1st task? Did I understand that correctly?

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 11:51

Yeah thats it ! Redirection to the second form after executing the first one ! And thats supposed To be happening outside the Portal home page thats why I need the urls To make it work in my frontend application

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 11:57

Ok, so, if I understand this correctly, you have the id of the second task and you just need the URL of the 2nd task. Did I understand that correctly?

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 12:09

After executing the first task , I added a call to the request `/bonita/API/bpm/humanTask?c=50&d=rootContainerId&f=state%3Dready&f=caseId=${caseId}` to get the ready tasks filtered by the caseId , and in the response I should be getting the ready task so from that response I could get The id of the task and then injecting it in my URL http://localhost:port/bonita/form?displayConfirmation=false&id={{taskId}}" to be redirected to the form of my second form , but it seems that I always get empty response even when I check in the portal , the Task exists , Thats the issue

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 12:48

This seems very strange indeed, could you look at the API call that is made when executing the first task, is it " API/bpm/userTask/{taskId}/execution "? Does it have no content? Does it return a 204?

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 13:20

yes it returns 204 !

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 14:13

I have a question ! How to refresh the task list in the portal without pressing the refresh button Next to Task List ?

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 14:30

Refreshing the task list without pressing the refresh button is currently impossible. The only way to do this is make a new API call to get the updated list of tasks (either through pressing the refresh button or after there were changes that were made in the portal (like executing a task)).

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 14:49

One of my colleagues suggested for you to check if the caseId that is passed to the request when getting the list of cases is the correct one. You can check this in the list of cases in the Portal or try to make the API call without the caseId and seeing if it gives you the good results. After that either use the debugger or simply print the value of the caseId during the execution into the console and then check that the value is correct.

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 15:41

I tried sending request to this URL `/bonita/API/bpm/humanTask?c=50&d=rootContainerId&f=state%3Dready' and its giving me results , but when ever I add a filter ' `/bonita/API/bpm/humanTask?c=50&d=rootContainerId&f=state%3Dready'&f=processId={{processId}}' or I add CaseId , it's always returning [] even though the tasks exists ! why is that ?

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 15:57

It might be that the processId value or the caseId value that are used are wrong, could you check that the value of the caseId or the processId are correct?

Submitted by fatma.ghorbel_1... on Wed, 05/20/2020 - 16:04

yes it's shown in the request URL , so Im sure it's the correct one !

Submitted by dumitru.corini_... on Wed, 05/20/2020 - 16:22

Could you try "f=processDefinitionId={processId}" instead of the processId filter?

Submitted by fatma.ghorbel_1... on Thu, 05/21/2020 - 11:47

the problem why I was getting [] as a response, is there is a missing delay I needed to add after executing the task and getting the task list by simply adding a setTimeout() function to call the URL "`/bonita/API/bpm/humanTask?c=50&d=rootContainerId&f=state%3Dready&f=caseId=${caseId}" , and it worked !

Submitted by fatma.ghorbel_1... on Thu, 05/21/2020 - 17:19

why in portal , just one task is shown even though I've created many cases ? so whenever I call this URL

`/bonita/API/bpm/humanTask?c=50&d=rootContainerId&f=state%3Dready" , I don't get all the list of the available tasks ?

Submitted by dumitru.corini_... on Tue, 05/26/2020 - 09:00

There might be many reasons why. Are all the tasks created by the process human tasks? Do you have an actor that is setup for the tasks and your user is not mapped to that actor? If you use the Studio, do you always run the process from the Studio?

Submitted by fatma.ghorbel_1... on Tue, 05/26/2020 - 15:12

Actually when I create the new case from the portal (go to navbar/process/), the list of different cases and tasks are shown , but whenever I run the process from the studio and then create the case using the start button or any instantiation form , just the first task is shown related to that created case ! I don't know what's the problem ! And by the way , I have just one actor which is the default one "water bases"

Submitted by dumitru.corini_... on Tue, 05/26/2020 - 17:24

If you run a process through the Studio, it deletes the process on your server and reinstalls it, to take into account any changes that were made to the process. Deleting the process deletes all cases that are related to it, thus all currently running cases and tasks are deleted. So, after you instantiate the process, you have only the first task of your process and you lose all previous instances. You can have a page that lists the processes and a button next to each process that lets you run the process.

Submitted by fatma.ghorbel_1... on Thu, 05/28/2020 - 12:08

I thought that the cases and its related tasks are always stored in the server ! so that's why I was getting always an empty list with just the first current task of that just started case. But I made a page and I wanted to retrieve the tasks available just like in the portal and then I would get the related information based on the taskId or to show its form. what would you suggest instead ?

Submitted by dumitru.corini_... on Thu, 05/28/2020 - 13:05

Just for me to understand, did you make a page listing the tasks available? Are you asking about how to make this page?

Submitted by fatma.ghorbel_1... on Thu, 05/28/2020 - 13:36

Yeah I made it but you know the problem , when starting a new case from the studio , its gonna give me just the first task !

Submitted by dumitru.corini_... on Thu, 05/28/2020 - 13:51

Ok, sorry, I made a mistake, I meant to say that you need a page listing the processes that are currently installed, that would let you start a process without going back to the studio. Starting the process from that page will not reinstall the process, but only start a new case.

Submitted by dumitru.corini_... on Thu, 05/28/2020 - 13:55

You could also think of other ways to start a process, like a modal container with the list of processes and a start button next to each, or a dropdown listing all the processes and start the process selected.
The main thing is to not start a process from studio since that reinstalls the process.

Notifications