Hi Team,
I need to popluate custom pop-up message to Author, incase if the workflow that authored trigger is Success or Some error. How to do this.
Usecase:
1- Author trigger a workflow in page like
2- Author can able to see the success message
I have created a workflow custom process step, which is checking the allowed usergroup in order to execute business logic.
@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
String payload = workItem.getWorkflowData().getPayload().toString();
ResourceResolver resourceResolver = resourceResolverUtil.getResourceResolver();
Session session = resourceResolver.adaptTo(Session.class);
String workflowInitiator = workItem.getWorkflow().getInitiator();
//usermanager object
UserManager userManager = resourceResolver.adaptTo(UserManager.class);
//getting user from workflowInitiator
try {
if(userManager != null){
User use = (User) userManager.getAuthorizable(workflowInitiator);
if(user!=null){
Iterator<Group> groupIterator = user.memberOf();
List<String> allowedUserGroups = new ArrayList<>();
// Adding random values to the list
allowedUserGroups.add("allowed_group_ID_1");
allowedUserGroups.add("allowed_group_ID_2");
allowedUserGroups.add("allowed_group_ID_3");
allowedUserGroups.add("allowed_group_ID_4");
while (groupIterator.hasNext()) {
Group currentGroup = groupIterator.next();
String groupID = currentGroup.getID();
//Check the group id with the configured allowed group id
if (allowedUserGroups.contains(groupID)) {
//Code to do operation
break;
}
else{
//Display Pop-up error message to Author Saying the user doesn't belongs
}
}
}
}
} catch (RepositoryException e) {
throw new RuntimeException(e);
} finally {
if (resourceResolver.isLive()) {
resourceResolver.close();
}
}
}
Now I need help here is the user who trigger workflow doesn't belong to the group will be moved out of if()condition.
Then How to populate the same error message to Author as we can see success in point -2
Thanks
@kautuk_sahni @shubhanshu_singh @arunpatidar @lukasz-m
Views
Replies
Total Likes
Hi @Marcos_aem
In this use case, you can overlay the error/success message and show your custom message as needed.
Hope it helps!
Thanks,
Kiran Vedantam.
Hi @Kiran_Vedantam , correct but which file do I need to overaly.
@Marcos_aem , If the intention is to restrict that only certain user groups are allowed to run the workflow, wouldn't using render condition on 'Create Workflow' make more sense here?