How Do I Use the getPermittedActions Function?
![]() I am creating a server-side follow-up action that modifies a work item after a user has hit save while making a specific change. My follow-up action modifies the description attribute (which is not the same attribute that the user touched). I want to handle the case where the user had permissions to modify the custom attribute that I care about, but they do not have permissions to modify the description field. In this case, if I don't catch that scenario, my follow-up action will fail and will prevent the user from being able to save the work item. I would prefer for my follow-up action to fail silently and allow the user to commit their save. In researching this, I found a function that seems promising, the IServerProcess#getPermittedActions function. The description for the function reads:
Here is how I've tried to use it so far:
I'm not sure if I'm populating my "actionList" with the correct values. The values shown above were to try and catch either possibility. Evidently the function doesn't have issues if you pass it an action that doesn't exist. For the case above, I changed the permissions in my test project area so that I could not modify the description field, then I ran the follow-up action. The resultPermissions array contained "false, false" for both actions. I then changed the permissions to re-enable the ability to modify the description and triggered the follow-up action again. The result was still "false, false". This suggests to me that I have not picked either the correct actions or the correct projectOperationId. Has anyone used this function before? Can you describe how to use it correctly? |
One answer
![]()
I don't know how to use this, and will have to read the code that implements the getPermittedActions to figure it out.
you can see the defined operations and actions by looking at the plugin.xml for com.ibm.team.workitem.service in the sdk. the start of the list is <operation id="com.ibm.team.workitem.operation.workItemSave" name="%SaveWorkItem.operation.name" categoryId="com.ibm.team.workitem.category" allowsPermissionSpecification="true" allowsBehaviorSpecification="true"> <action id="modify" label="%ModifyWorkItem.action.name"> <action id="projectArea" label="%ModifyWorkItemProjectArea.action.name"> <description> %ModifyWorkItemProjectArea.action.description </description> </action> Looks like you are close, operation_id, followed by array of strings of action_ids the action id for description is <action id="description" label="%ModifyWorkItemDescription.action.name"> <description> %ModifyWorkItemDescription.action.description </description> </action> Comments I also found a page that lists all of the operations and their ids: https://jazz.net/wiki/bin/view/Main/CustomPreconditionsTable#operations It looks like "modify/description" should be valid and so should my "com.ibm.team.workitem.operation.workItemSave". So I'm not sure why it doesn't work. I don't think its "modify/..." cause that is not one of the id= fields for the actions
the code for this runs thru all the roles for this user in this project area and then checks the actions.
|