Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why

Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Luca Lupo
Kaleo Single Approver - change sending email
October 27, 2012 3:53 PM
Answer

Luca Lupo

Rank: Regular Member

Posts: 106

Join Date: October 1, 2012

Recent Posts

Hi Guys,

I'm working with Kaelo Single Approver. Thanks to a suggestion from the community I already modified Kaleo Single Approver workflow so that if the "Administrator" or a user with role "Publisher" creates a content, its status is "Approved" and not "Pending". The code below if you are interested.

Now I need to customize the email sending. In particular I have the following needs:

- When someone that is not the "Administrator" nor the "Publisher" creates a content, an email has to be sent to all users that have the role "Publisher" to advise them that there is a new content that has to be reviewed and approved/rejected.

- When a "Publisher/Administrator" assign to someone the review of the content, this someone has to receive an email.

- When a "Publisher" approve/reject a content, the user who created the content has to receive the email; moreover, also all the publishers need to receive an email in order to be informed that there is not need anymore to approve/reject the content, because someone else took care of it.

Any help will be appreciated emoticon

Thanks

Luca

  1
  2<?xml version="1.0"?>
  3<workflow-definition
  4    xmlns="urn:liferay.com:liferay-workflow_6.1.0"
  5    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  6    xsi:schemaLocation="urn:liferay.com:liferay-workflow_6.1.0 http://www.liferay.com/dtd/liferay-workflow-definition_6_1_0.xsd">
  7   
  8    <name>Single Approver</name>
  9    <description>A single approver can approve a workflow content.</description>
 10    <version>1</version>
 11
 12     <state>
 13            <name>created</name>
 14            <initial>true</initial>
 15            <transitions>
 16                <transition>
 17                    <name>Determine Review</name>
 18                    <target>review-or-approve</target>
 19                    <default>true</default>
 20                </transition>
 21            </transitions>
 22    </state>
 23    <condition>
 24        <name>review-or-approve</name>
 25        <script> <![CDATA[
 26                        import com.liferay.portal.service.RoleLocalServiceUtil;
 27                        import com.liferay.portal.kernel.util.GetterUtil;
 28                        import com.liferay.portal.kernel.workflow.WorkflowConstants;
 29
 30                        try {
 31                                returnValue = "Review";
 32                                long userid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_USER_ID));
 33                                long companyid = GetterUtil.getLong((String)workflowContext.get(WorkflowConstants.CONTEXT_COMPANY_ID));
 34                                String[] roles={"Publisher","Administrator"};
 35                                if (RoleLocalServiceUtil.hasUserRoles(userid, companyid, roles, true)) returnValue = "Approved";
 36                        } catch (Exception e) {
 37                          e.printStackTrace();
 38                        }
 39                ]]> </script>
 40        <script-language>beanshell</script-language>
 41        <transitions>
 42                <transition>
 43                        <name>Review</name>
 44                        <target>review</target>
 45                        <default>false</default>
 46                </transition>
 47                <transition>
 48                        <name>Approved</name>
 49                        <target>approved</target>
 50                        <default>false</default>
 51                </transition>
 52        </transitions>
 53    </condition>
 54    <task>
 55        <name>update</name>
 56        <metadata>
 57            <![CDATA[{"transitions":{"resubmit":{"bendpoints":[[303,140]]}},"xy":[328,199]}]]>
 58        </metadata>
 59        <actions>
 60            <action>
 61                <name>reject</name>
 62                <script>
 63                    <![CDATA[
 64                        Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("denied"), workflowContext);
 65                        Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("pending"), workflowContext);
 66                    ]]>
 67                </script>
 68                <script-language>javascript</script-language>
 69                <execution-type>onAssignment</execution-type>
 70            </action>
 71            <notification>
 72                <name>Creator Modification Notification</name>
 73                <template>Your submission was rejected by a reviewer, please modify and resubmit.</template>
 74                <template-language>text</template-language>
 75                <notification-type>email</notification-type>
 76                <execution-type>onAssignment</execution-type>
 77            </notification>
 78        </actions>
 79        <assignments>
 80            <user />
 81        </assignments>
 82        <transitions>
 83            <transition>
 84                <name>resubmit</name>
 85                <target>review</target>
 86            </transition>
 87        </transitions>
 88    </task>
 89    <task>
 90        <name>review</name>
 91        <metadata>
 92            <![CDATA[{"xy":[168,36]}]]>
 93        </metadata>
 94        <actions>
 95            <notification>
 96                <name>Review Notification</name>
 97                <template>You have a new submission waiting for your review in the workflow.</template>
 98                <template-language>text</template-language>
 99                <notification-type>email</notification-type>
100                <execution-type>onAssignment</execution-type>
101            </notification>
102            <notification>
103                <name>Review Completion Notification</name>
104                <template>
105                    Your submission has been reviewed and the reviewer has applied the following ${taskComments}.</template>
106                <template-language>freemarker</template-language>
107                <notification-type>email</notification-type>
108                <recipients>
109                    <user />
110                </recipients>
111                <execution-type>onExit</execution-type>
112            </notification>
113        </actions>
114        <assignments>
115            <roles>
116                <role>
117                    <role-type>organization</role-type>
118                    <name>Organization Administrator</name>
119                </role>
120                <role>
121                    <role-type>organization</role-type>
122                    <name>Organization Content Reviewer</name>
123                </role>
124                <role>
125                    <role-type>organization</role-type>
126                    <name>Organization Owner</name>
127                </role>
128                <role>
129                    <role-type>regular</role-type>
130                    <name>Administrator</name>
131                </role>
132                <role>
133                    <role-type>regular</role-type>
134                    <name>Portal Content Reviewer</name>
135                </role>
136                <role>
137                    <role-type>site</role-type>
138                    <name>Site Administrator</name>
139                </role>
140                <role>
141                    <role-type>site</role-type>
142                    <name>Site Content Reviewer</name>
143                </role>
144                <role>
145                    <role-type>site</role-type>
146                    <name>Site Owner</name>
147                </role>
148            </roles>
149        </assignments>
150        <transitions>
151            <transition>
152                <name>approve</name>
153                <target>approved</target>
154            </transition>
155            <transition>
156                <name>reject</name>
157                <target>update</target>
158                <default>false</default>
159            </transition>
160        </transitions>
161    </task>
162    <state>
163        <name>approved</name>
164        <metadata>
165            <![CDATA[
166                {"xy":[380,51]}
167            ]]>
168        </metadata>
169        <actions>
170            <action>
171                <name>approve</name>
172                <script>
173                    <![CDATA[
174                        Packages.com.liferay.portal.kernel.workflow.WorkflowStatusManagerUtil.updateStatus(Packages.com.liferay.portal.kernel.workflow.WorkflowConstants.toStatus("approved"), workflowContext);
175                    ]]>
176                </script>
177                <script-language>javascript</script-language>
178                <execution-type>onEntry</execution-type>
179            </action>
180        </actions>
181    </state>
182</workflow-definition>
Imran Khalil
RE: Kaleo Single Approver - change sending email
November 12, 2012 9:39 PM
Answer

Imran Khalil

Rank: Junior Member

Posts: 36

Join Date: October 21, 2012

Recent Posts

How did you add this definition...?
Milan Kostoláni
RE: Kaleo Single Approver - change sending email
November 13, 2012 1:54 AM
Answer

Milan Kostoláni

Rank: Junior Member

Posts: 92

Join Date: July 26, 2012

Recent Posts

LR portal -> tomcat -> webapps -> kaleo-web -> WEB-INF ->src ->META-INT -> definitions
Imran Khalil
RE: Kaleo Single Approver - change sending email
November 13, 2012 2:22 AM
Answer

Imran Khalil

Rank: Junior Member

Posts: 36

Join Date: October 21, 2012

Recent Posts

Milan Kostoláni:
LR portal -> tomcat -> webapps -> kaleo-web -> WEB-INF ->src ->META-INT -> definitions



i did the same but didnt get it working emoticon
Milan Kostoláni
RE: Kaleo Single Approver - change sending email
November 14, 2012 1:26 AM
Answer

Milan Kostoláni

Rank: Junior Member

Posts: 92

Join Date: July 26, 2012

Recent Posts

Ah sorry, I miss read your question emoticon

You have to open your portal and control panel, Portal -> Workflow -> Add
Imran Khalil
RE: Kaleo Single Approver - change sending email
November 14, 2012 1:59 AM
Answer

Imran Khalil

Rank: Junior Member

Posts: 36

Join Date: October 21, 2012

Recent Posts

tried but no output... Can u send me edited file that will send emails to all portal administrators.??

Plz help..
Vishal Panchal
RE: Kaleo Single Approver - change sending email
November 15, 2012 10:27 PM
Answer

Vishal Panchal

Rank: Expert

Posts: 279

Join Date: May 20, 2012

Recent Posts

Imran Khalil:
tried but no output... Can u send me edited file that will send emails to all portal administrators.??

Plz help..


Hi Imran,

First of all let us know whether you are having any error while uploading the definition file from control panel -> Portal -> Workflow -> Add..?

and yes,
you can find one sample workflow definition (having email notification ready) @ following location.

{liferay-home}\tomcat-7.0.27\webapps\kaleo-web\WEB-INF\classes\META-INF\definitions
or please find the attached file and try to upload the same.


Thanks&Regards,
Vishal R. Panchal
Attachments: single-approver-definition.xml (4.4k)
Imran Khalil
RE: Kaleo Single Approver - change sending email
November 19, 2012 2:12 AM
Answer

Imran Khalil

Rank: Junior Member

Posts: 36

Join Date: October 21, 2012

Recent Posts

SOLVED and thanks all for you replies.
I did it with scripting...
Vishal Panchal
RE: Kaleo Single Approver - change sending email
November 19, 2012 2:19 AM
Answer

Vishal Panchal

Rank: Expert

Posts: 279

Join Date: May 20, 2012

Recent Posts

Great..!
Imran Khalil
RE: Kaleo Single Approver - change sending email
November 19, 2012 2:25 AM
Answer

Imran Khalil

Rank: Junior Member

Posts: 36

Join Date: October 21, 2012

Recent Posts

Thanks Vishal... I need some more help plz...

1- how can i send flag notifications to the creator of content
2- why kaleo do not sends email notification on user account rejection...

Waiting...