07-19-2017 09:45 AM
We have a workflow where users may request access to various programs external to Activiti. The request must then be approved by that individual's manager, who is specified in the request using the "People" form item.
A manager should be able to request special permissions on behalf of someone else, and then not have to approve this request.
How do I compare the User selected in the "People" form item to the user produced by userInfoBean.getCurrentUser()?
This is my Java Code:
//Establish request_originator
var currentUser = userInfoBean.getCurrentUser()
execution.setVariable('request_originator', currentUser);//Compare to selected manager
var originatorIsManager = 'foobar'
if(currentUser.equals(execution.getVariable('manager_of_requested_for'))){
originatorIsManager = 'yes';
} else {
originatorIsManager = 'no';
}execution.setVariable('originator_is_manager', originatorIsManager);
See the attached image, where I display the values being returned by my Variable and the Form Field. They are identical, but my comparison is still being returned as "no."
Thank you.
07-20-2017 10:21 AM
Since you are comparing execution.getVariable('manager_of_requested_for') which will be the "ID" of manager_of_requested_for, you need to get currentUser's ID for the comparison. Set currentUser as below
var currentUser = userInfoBean.getCurrentUser().getId()
07-20-2017 10:21 AM
Since you are comparing execution.getVariable('manager_of_requested_for') which will be the "ID" of manager_of_requested_for, you need to get currentUser's ID for the comparison. Set currentUser as below
var currentUser = userInfoBean.getCurrentUser().getId()
Explore our Alfresco products with the links below. Use labels to filter content by product module.