Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Need to get the Asset Creator / User id in the Workflow
Dear All,
We have developed a simple liferay form (named as customer satisfaction details) which consist of 10 fields.
We have also assigned a simple workflow (Approver will approve the details) to this form (customer satisfaction details form).
Now we want to get the user id (Who has submitted the details).
Steps tried:
1. WorkflowConstants.CONTEXT_USER_ID --> Gives context user id (When approver appoves the details, we need user id of the Initiator / Asset creator)
2. We checked for the Workflowintancelink table to get the details of userid.
3. we also checked the below URL
https://dev.liferay.com/discover/portal/-/knowledge_base/7-0/leveraging-the-script-engine-in-workflow
We tried to importing the "AssetCategory" but it gave an error in the groovy script.
Regards
Dinesh
We have developed a simple liferay form (named as customer satisfaction details) which consist of 10 fields.
We have also assigned a simple workflow (Approver will approve the details) to this form (customer satisfaction details form).
Now we want to get the user id (Who has submitted the details).
Steps tried:
1. WorkflowConstants.CONTEXT_USER_ID --> Gives context user id (When approver appoves the details, we need user id of the Initiator / Asset creator)
2. We checked for the Workflowintancelink table to get the details of userid.
3. we also checked the below URL
https://dev.liferay.com/discover/portal/-/knowledge_base/7-0/leveraging-the-script-engine-in-workflow
We tried to importing the "AssetCategory" but it gave an error in the groovy script.
Regards
Dinesh
What do you mean, "asset creator"? The creator of the form or the person filling out the form?
The person filling out the form will be tied to the user id of the form data itself, you don't have to go digging through the asset framework to find them.
The person filling out the form will be tied to the user id of the form data itself, you don't have to go digging through the asset framework to find them.
David H NebingerWhat do you mean, "asset creator"? The creator of the form or the person filling out the form?
The person filling out the form will be tied to the user id of the form data itself, you don't have to go digging through the asset framework to find them.
Dear David,
Thanks
As said user ID will stored in the form, but i need this user id for sending a mail to user id marking the approver cc in the mail.we are using Liferay 7.0.
We tried with workflow constant but it gives approver user id when approver approves the details
We also found that in Liferay 7.1 we have option for marking cc mail in workflow.
Can you suggest me an option to send an email to form requestor marking the approver cc.
Regards
Dinesh
Can anyone suggest me with corresponding liferay API which can be imported using groovy script
No, but I don't think any of that would help really...
I mean, a notification goes out when a new task arrives, but this may or may not be a single person (in fact, best practice says to never use a single person).
I have no idea what you are trying to do, but if it were along the lines of sending a notification, I'd probably find the source for the current notification classes and see how they are doing it.
I mean, a notification goes out when a new task arrives, but this may or may not be a single person (in fact, best practice says to never use a single person).
I have no idea what you are trying to do, but if it were along the lines of sending a notification, I'd probably find the source for the current notification classes and see how they are doing it.
Thanks David.
Let me also check the other api for solving this problem.
Also attached the detail of Workflow
Let me also check the other api for solving this problem.
Also attached the detail of Workflow
Attachments:
But the approver has approved? They don't already know that they approved?
In either case, this might be doable using a standard notification configuration.
In either case, this might be doable using a standard notification configuration.
David H NebingerBut the approver has approved? They don't already know that they approved?
In either case, this might be doable using a standard notification configuration.
hi David,
Approver knows they have approved the request but we have many requests & for some request, it might be rejected for certain reasons. If user request for similar kind of activity then these kind of mail with marking cc to approver.
Regards
Dinesh
Can't you just sent the notification to <user /> and<assignees />?
I did not test this, just copied a task from some workflow notification and added assignees:
Please don't forget that you can use multiple notification entries, so you could send a mail to the user and maybe a different mail to the assignee.
I did not test this, just copied a task from some workflow notification and added assignees:
<state>
<name>approved</name>
<metadata>{"xy":[850,50],"terminal":true}</metadata>
<actions>
<action>
<name>approve</name>
<script>
<![CDATA[
import com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil
import com.liferay.portal.kernel.workflow.WorkflowConstants
WorkflowStatusManagerUtil.updateStatus(WorkflowConstants.getLabelStatus("approved"), workflowContext)]]>
</script>
<script-language>groovy</script-language>
<execution-type>onEntry</execution-type>
</action>
<action>
<name>prepareEmail</name>
<script>
<![CDATA[
import com.liferay.portal.kernel.service.ServiceContext
import com.liferay.portal.kernel.workflow.WorkflowConstants
ServiceContext serviceContext = (ServiceContext) workflowContext.get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT)
Map<String, Serializable> attributes = serviceContext.getAttributes()
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME, "Workflow (do not reply)")
workflowContext.put(WorkflowConstants.CONTEXT_NOTIFICATION_SUBJECT, "Artikel " + attributes.get("title") + " genehmigt")]]></script>
<script-language>groovy</script-language>
<execution-type>onEntry</execution-type>
</action>
<notification>
<name>Approved Notification</name>
<template>
<#assign
attributes = serviceContext.getAttributes()
articleId = attributes["articleId"]
articleTitle = attributes["title"]
articleVersion = attributes["version"]
/>
Guten Tag,<br>
<br>
das ist ein automatisch generiertes Email für ${entryType}.<br>
<br>
Ihr Artikel mit der Nummer ${articleId} und Version ${articleVersion} und Titel ${articleTitle} wurde genehmigt.<br>
<br>
</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<recipients>
<user />
<assignees />
</recipients>
<execution-type>onEntry</execution-type>
</notification>
</actions>
</state>
Please don't forget that you can use multiple notification entries, so you could send a mail to the user and maybe a different mail to the assignee.
hi Christoph Rabel,
Thanks for the Reply.
The snippet provided was related to webcontent.
We are using forms & entries are getting into asset entry table.
We have even tried the following link to get the user data but we are not getting data.
https://dev.liferay.com/discover/portal/-/knowledge_base/7-0/leveraging-the-script-engine-in-workflow
Regards
Dinesh
Thanks for the Reply.
The snippet provided was related to webcontent.
We are using forms & entries are getting into asset entry table.
We have even tried the following link to get the user data but we are not getting data.
https://dev.liferay.com/discover/portal/-/knowledge_base/7-0/leveraging-the-script-engine-in-workflow
Regards
Dinesh