如何在任务脚本中获取用户名?
我在工作流程中有一个任务,该任务在后端调用了一项服务,该服务以及从任务发送的其他数据等待执行该任务的用户的名称。
如何在用groovy编写的任务脚本中获取用户或用户名?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我在工作流程中有一个任务,该任务在后端调用了一项服务,该服务以及从任务发送的其他数据等待执行该任务的用户的名称。
如何在用groovy编写的任务脚本中获取用户或用户名?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
您的意思是按用户任务执行脚本任务?假设您想访问从脚本完成以前用户任务的用户的名称,则可以在完成时将用户名存储在过程数据中,如下所示:
grovyprocess.bpmn
You mean a script task following a user task? Assuming you would like to access the name of the user who completed the previous user task from your script, you can store the user name on completion in a process data as shown here:
https://github.com/rob2universe/bpmrun-add-to-dockerimg/blob/e2dd62122b7d006a8a719be96b0a3d043efc9851/configuration/resources/groovyprocess.bpmn#L23
You can then subsequently access the process data in the groovy script task like this:
https://github.com/rob2universe/bpmrun-add-to-dockerimg/blob/e2dd62122b7d006a8a719be96b0a3d043efc9851/configuration/resources/groovyprocess.bpmn#L18
您可以按照@rob2universe 提到的任务受让人,也可以使用
excution
对象,始终可以从脚本访问(请参阅“ nofollow noreferrer”> camunda docs )如下:参见 IdentityService 。
然后可以将用户名保存到流程变量:
并访问:
You could either get the task assignee as mentioned by @rob2universe, or make use of the
execution
object, which is always accessible from the script (see Camunda Docs), as follows:See IdentityService.
The username can be then saved to a process variable:
And accessed: