RE: Writing a personal portlet is like a Asset PublisherRE: Writing a personal portlet is like a Asset Publisherhttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1145911412024-03-29T06:50:22Z2024-03-29T06:50:22ZRE: Writing a personal portlet is like a AssetVahid Khhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1173210152019-09-29T12:03:39Z2019-09-29T12:03:39ZBut in workflow only we have one action that is doing task transitions, and ActionKeys.VIEW and ActionKeys.ADD_ENTRY is meaningless for it.<br />When a task assigned to a role , all user has this role must can do all transitions on that specific task.<br />Normally it is expected there should be a utility that receive <strong>taskId </strong>and check if task is assigned to one of current user Roles or task assigned to itself user, It must return trueVahid Kh2019-09-29T12:03:39ZRE: Writing a personal portlet is like a AssetMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1148117122019-08-20T04:48:26Z2019-08-20T04:48:26ZYou can try ActionKeys.VIEW or ActionKeys.ADD_ENTRY for actionIdMohammed Yasin2019-08-20T04:48:26ZRE: Writing a personal portlet is like a AssetVahid Khhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1148095372019-08-19T23:49:25Z2019-08-19T23:49:25ZNo, I create two different Users have two different Roles (admin1, admin2)<br /><strong>I think , I have a problem in Method Parameters<br /></strong>Exactly, What is the means of any parameters, especially last (actionId) ?Vahid Kh2019-08-19T23:49:25ZRE: Writing a personal portlet is like a AssetMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147296142019-08-11T08:10:57Z2019-08-11T08:10:57ZIdeally <strong><strong>WorkflowPermissionUtil.<em>hasPermission</em>()</strong></strong> should work and it does work and it is utility for checking permission in workflow, did you check <strong><strong>WorkflowPermissionUtil.<em>hasPermission</em>()</strong></strong> with compant or site admin user? because there it might give you true in any condition.Mohammed Yasin2019-08-11T08:10:57ZRE: Writing a personal portlet is like a AssetVahid Khhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147315442019-08-11T07:43:24Z2019-08-11T07:43:24Z<html><head></head><body>Yes it works !<br>Thanks very much,<br>My sample code:<br><pre><code>List<workflowtaskassignee> workflowTaskAssignees = task.getWorkflowTaskAssignees();
List<role> userRoles = RoleLocalServiceUtil.getUserRoles(userId);
Boolean hasPersmission = false;
for(Role role:userRoles){
for(WorkflowTaskAssignee assignee:workflowTaskAssignees){
if(assignee.getAssigneeClassPK() == role.getRoleId()) {
hasPersmission = true;
}
}
}
if(hasPersmission){
WorkflowTaskManagerUtil.completeWorkflowTask( companyId, userId, taskId, transition, "task is done !!!" , workflowContext );
}</role></workflowtaskassignee></code></pre><br>But are you sure it's the best solution ? <br>What is the usage of method <strong>WorkflowPermissionUtil.<em>hasPermission</em>()</strong> ?</body></html>Vahid Kh2019-08-11T07:43:24ZRE: Writing a personal portlet is like a AssetMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147292802019-08-11T06:34:02Z2019-08-11T06:34:02ZAre you sure that workflowTask.getWorkflowTaskAssignees(0).getAssigneeClassPK( ) is primary key of resource Permission table? , It should be classpK for role table or user table based on workflowTask.getWorkflowTaskAssignees(0).getAssigneeClassName<strong><strong>()</strong></strong>Mohammed Yasin2019-08-11T06:34:02ZRE: Writing a personal portlet is like a Asset PublisherVahid Khhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147288742019-08-11T06:11:41Z2019-08-11T06:11:41Z<strong>workflowTask.getWorkflowTaskAssignees()</strong> return a list of <strong>WorkflowTaskAssignee </strong>object that only has two method <br /><strong>1. getAssigneeClassPK()</strong><br /><strong>2.getAssigneeClassName()</strong>getAssigneeClassPK() return an primary key of resource Permission table <span style="font-size: 16px;">, How can I check current user has permission to complete this task with this PK?</span>Vahid Kh2019-08-11T06:11:41ZRE: Writing a personal portlet is like a AssetMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146948412019-08-10T16:27:31Z2019-08-10T16:27:31Z<div class="quote-title">Vahid Kh:</div><blockquote><br />I have this problem too<br /><br /><strong>WorkflowTaskManagerUtil.completeWorkflowTask()</strong> dose not return any exception and it execute successfully even for Guest users, I think it has no permission checking .<br /><br />for filtering task by user or role:<br />Yes maybe this solution be correct but it's not complete , I want to check permission in my action method<br />---------------------------------------------------<em></em><strong>My Problem With Details:</strong><em><strong><br /></strong> My scenario:<br /> I have two step approval workflow like attachment image</em><em></em>task review1 assigned to admin1 and task review2 assigned to admin2<br />I design a custom user interface for my portlet that user can see list of transition of current task for every entity row and click it (for example approve) and clicked button send transition name to a action method , in action method I fetch current task name and call <strong>WorkflowPermissionUtil.<em>hasPermission() </em></strong>method for checking that current user has required permission to complete this task and if true , I call <strong>WorkflowTaskManagerUtil.completeWorkflowTask() </strong>method for completing task.<br />but the problem is here that <strong>WorkflowPermissionUtil.<em>hasPermission() </em></strong>return true for both admin1 and admin2 role while current user only has admin2 role.<br />for more details I attach XML workflow file and my action method codes</blockquote><br />Hi ,<br /> Have you tried workflowTask.getWorkflowTaskAssignees() here you will get assignees list which you can use to check whether role is assigned or not Mohammed Yasin2019-08-10T16:27:31ZRE: Writing a personal portlet is like a Asset PublisherVahid Khhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147281722019-08-10T13:14:50Z2019-08-10T13:14:50ZI have this problem too<br /><br /><strong>WorkflowTaskManagerUtil.completeWorkflowTask()</strong> dose not return any exception and it execute successfully even for Guest users, I think it has no permission checking .<br /><br />for filtering task by user or role:<br />Yes maybe this solution be correct but it's not complete , I want to check permission in my action method<br />---------------------------------------------------<em></em><strong>My Problem With Details:</strong><em><strong><br /></strong> My scenario:<br /> I have two step approval workflow like attachment image</em><em></em>task review1 assigned to admin1 and task review2 assigned to admin2<br />I design a custom user interface for my portlet that user can see list of transition of current task for every entity row and click it (for example approve) and clicked button send transition name to a action method , in action method I fetch current task name and call <strong>WorkflowPermissionUtil.<em>hasPermission() </em></strong>method for checking that current user has required permission to complete this task and if true , I call <strong>WorkflowTaskManagerUtil.completeWorkflowTask() </strong>method for completing task.<br />but the problem is here that <strong>WorkflowPermissionUtil.<em>hasPermission() </em></strong>return true for both admin1 and admin2 role while current user only has admin2 role.<br />for more details I attach XML workflow file and my action method codesVahid Kh2019-08-10T13:14:50ZRE: Writing a personal portlet is like a Asset PublisherMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146386222019-08-07T12:13:47Z2019-08-07T12:13:47Zwhen you use WorkflowTaskManagerUtil.completeWorkflowTask(companyId, userId, workflowTaskId, transitionName, comment, workflowContext) for completing transaction , you are not getting exception when user to whom its not assign perform the task ?<br /><br />Also when getting the task for role or user your are filtering only those task assinged to the role right ?<br /><br />if you use the workflowTask.getWorkflowTaskAssignees() here you will get assigness list which you can use to check whether role is assigned or not Mohammed Yasin2019-08-07T12:13:47ZRE: Writing a personal portlet is like a Asset Publisherali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146366232019-08-07T11:27:40Z2019-08-07T11:27:40ZWhat is the actionId here? It mean workflow current task name ?<br />If your answer is yes<br />I do that but I have a problem:<br />this is my workflow scenario<br />I have two level review named review1 and review2 that assigned to two different role named admin1 and admin2<br />with this scenario a user in admin2 role should not be able to complete a transition on task review1 because not assigned to his role<br />But hasPermission method return trueali yeganeh2019-08-07T11:27:40ZRE: Writing a personal portlet is like a Asset PublisherMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146335422019-08-07T07:22:20Z2019-08-07T07:22:20ZYou can try this for checking permission with user and action<br /> WorkflowPermissionUtil.hasPermission(permissionChecker, groupId, className, classPK, actionId).Mohammed Yasin2019-08-07T07:22:20ZRE: Writing a personal portlet is like a Asset Publisherali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146291292019-08-07T06:55:29Z2019-08-07T06:55:29ZI want to check that current signed in user has permission to complete selected transition <br />I do not use Assets for managing workflow in my custom portlet<br />and I control all functionality of workflow manually by workflkow Utitlity Classes<br />I want to check permission according to assigned role or users that defined in XML file.ali yeganeh2019-08-07T06:55:29ZRE: Writing a personal portlet is like a Asset PublisherMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146284392019-08-07T06:13:58Z2019-08-07T06:13:58ZDo you mean instead of assiging task to role you want to assign to user? If yes u can define this in workflow conifiguration fileMohammed Yasin2019-08-07T06:13:58ZRE: Writing a personal portlet is like a Asset Publisherali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146280932019-08-07T05:44:20Z2019-08-07T05:44:20ZOne more question<br /> Now with completeWorkflowTask method my problem is solved , but I want the only user in the xml file I defined to get permission to do it.ali yeganeh2019-08-07T05:44:20ZRE: Writing a personal portlet is like a Asset Publisherali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146099382019-08-05T12:53:14Z2019-08-05T12:53:14ZThank you very much<br />You helped a lotali yeganeh2019-08-05T12:53:14ZRE: Writing a personal portlet is like a Asset PublisherMohammed Yasinhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146092622019-08-05T11:32:59Z2019-08-05T11:32:59ZThere are couple of methods used in updation<br />//To perform action on task <br />WorkflowTaskManagerUtil.completeWorkflowTask(companyId, userId, workflowTaskId, transitionName, comment, workflowContext)<br />//Update Due Date<br />WorkflowTaskManagerUtil.updateDueDate(companyId, userId, workflowTaskId, comment, dueDate)Mohammed Yasin2019-08-05T11:32:59ZRE: Writing a personal portlet is like a Asset Publisherali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146085572019-08-05T10:24:43Z2019-08-05T10:24:43ZI had another question<br />How can i add a comment to a WorkflowInstance ?ali yeganeh2019-08-05T10:24:43ZRE: Writing a personal portlet is like a Asset Publisherali yeganehhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1146065452019-08-05T09:36:04Z2019-08-05T09:36:04ZI really thank