Discussion:
[jboss-user] [jBPM] - How to know who has started a process?
Andy McC
2013-04-30 14:37:40 UTC
Permalink
Andy McC [https://community.jboss.org/people/andymcc] created the discussion

"How to know who has started a process?"

To view the discussion, visit: https://community.jboss.org/message/810965#810965

--------------------------------------------------------------
What do I need to add to my process definition to access the Id of the user who has started the process?

For example, if I'm logged in to jbm-console as "John" and start a new process, what mechanism do I have to find out that it was "John" who started the process. (The available examples seem to rely on the task form associated with the start event)

There's quite an old post ( https://community.jboss.org/thread/116323 How to know who has started a process ?), suggesting that I need to add a swimlane to the Start task (I assume this means the Start Event), but as this option isn't available via the designer, do I need to hand-edit some additional xml into the Start Event definition?

Is there a better/official way?

Thanks,

Andy McC
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810965#810965]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Mauricio Salatino
2013-04-30 14:45:45 UTC
Permalink
Mauricio Salatino [https://community.jboss.org/people/salaboy21] created the discussion

"Re: How to know who has started a process?"

To view the discussion, visit: https://community.jboss.org/message/810968#810968

--------------------------------------------------------------
We are already storing that information inside the jBPM Console NG logs. What we are doing is to use the currently logged user and store it in the process execution logs. Then you can query those logs in order to pick up the information about which user started a process. You can take a look at the ProcessInstanceLog class which already has the place to store the identity of the user that is starting the process:

https://github.com/droolsjbpm/jbpm/blob/master/jbpm-bam/src/main/java/org/jbpm/process/audit/ProcessInstanceLog.java https://github.com/droolsjbpm/jbpm/blob/master/jbpm-bam/src/main/java/org/jbpm/process/audit/ProcessInstanceLog.java

Depending on how you get the currently logged user in your application is how you will fill this attribute.

Cheers
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810968#810968]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Andy McC
2013-04-30 15:30:17 UTC
Permalink
Andy McC [https://community.jboss.org/people/andymcc] created the discussion

"Re: How to know who has started a process?"

To view the discussion, visit: https://community.jboss.org/message/810978#810978

--------------------------------------------------------------
Thanks Mauricio - that's useful but my question probably wasn't clear enough.

What I'm trying to do is access the currently logged-in user Id, without having to ask that user to enter it via a form every time they start a task. I was hoping I could add a script task to my process and from that use a method call of some kind (e.g .via kcontext) to access an Id field or similar. I guess that's what you're suggesting I could do using the ProcessInstanceLog link, but for various reasons I'm constrained to use the 5.4.0.Final tooling so I'm not sure I can exploit the Console NG developments.

Where possible I'm trying to develop and deploy entirely from Drools-Guvnor and jbpm-console.

It may be that I fall into a particular class of jBPM user who is more heavily biased to the BPMN-side of things and I'll confess that I don't have a background in enterprise apps, so I'm climbing several steep learning curves every day! I'm heavily reliant on Drools-Guvnor for building and deployment my stuff with some modest Java API calls contained within Script tasks.

I can imagine that other users in my class would find it useful if the jbpm-console could automatically create, on start-up, a process global (e.g. processStartInfo?)  with some key fields similar to the ones you've linked to (e.g. initiator id, date/time etc). Do you think this is this a sufficiently common requirement that it would be worth me submitting a Jira request?

Thanks again for getting back,

Andy McC
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810978#810978]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Mauricio Salatino
2013-04-30 15:33:21 UTC
Permalink
Mauricio Salatino [https://community.jboss.org/people/salaboy21] created the discussion

"Re: How to know who has started a process?"

To view the discussion, visit: https://community.jboss.org/message/810980#810980

--------------------------------------------------------------
Hi Andy,
Maybe I wasn't clear enough. When I mention the "Currently Logged User" means the user logged in the application. If you are in a web application you can get that from the http session and your security framework as well. jBPM doesn't have that information for you, because that's application specific. In jBPM 5.4 you can do the same, you can provide your own ProcessListener that collect that information for you. Once again, notice that the Currently logged user is part of your application and how you handle security. How you know which user is executing each action in your app?

Cheers
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810980#810980]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Andy McC
2013-04-30 16:10:08 UTC
Permalink
Andy McC [https://community.jboss.org/people/andymcc] created the discussion

"Re: How to know who has started a process?"

To view the discussion, visit: https://community.jboss.org/message/810989#810989

--------------------------------------------------------------
Hi Mauricio,

Don't worry - your answer was clear - it's because I'm new to a lot of the technologies surrounding jBPM and as a result I am probably asking a lot of naive and quite dumb questions!

I can see what you're saying about the info being application specific. In this case I'm not writing an app of my own, the app is jbpm-console and the user security is the default login process that comes with the 5.4.0.Final installation. My assumption was that with the user already logged in and the creation of new process instances being managed by jbpm-consle that it would be relatively easy to access the user's name. If I understand correctly, as jbpm-console is a web application then I should be able to do that by accessing the session info (although that's another learning curve I'll be sitting at the bottom of! :) ).

Thanks again - I do appreciate it,

Andy McC
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810989#810989]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Mauricio Salatino
2013-04-30 16:14:41 UTC
Permalink
Mauricio Salatino [https://community.jboss.org/people/salaboy21] created the discussion

"Re: How to know who has started a process?"

To view the discussion, visit: https://community.jboss.org/message/810990#810990

--------------------------------------------------------------
Perfect Andy!
I'm not sure how is that working in the old jbpm console.. but you should do something similar. Just replace the current listener that probably is not storing the user that is logged in and store it. And then add that information in the process instance lists, like we are doing in the new console.

Cheers
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810990#810990]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Andy McC
2013-04-30 16:27:10 UTC
Permalink
Andy McC [https://community.jboss.org/people/andymcc] created the discussion

"Re: How to know who has started a process?"

To view the discussion, visit: https://community.jboss.org/message/810993#810993

--------------------------------------------------------------
Thanks again - although I'm meant to be using 5.4.0.Final I will take a look at the latest Console NG source and see how it's done.

Looking forward to 6.0!

Cheers
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810993#810993]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...