I got the same issue, in a certain moment a Claim Button has disappeared from the toolbar. There are some other similar questions about this functionality, but they are not answered.
So, I do some research, and find several intresting points.
When Claim Release Button work
For Claim Release Button is responding ClaimReleaseTaskButton class, which is located in
Microsoft.SharePoint.dll. Visibility of the button is controlled by private field
ButtonMode of type:
private enum CRButtonMode
To set value of this field in class called method
private ClaimReleaseTaskButton.CRButtonMode GetMode(SPControlMode mode, SPList l, SPListItem li, SPUser user)
if (mode != SPControlMode.Display && mode != SPControlMode.Edit || (l.BaseTemplate != SPListTemplateType.Tasks || li == null) || (li.IsNew || !li.DoesUserHavePermissionsForUI(SPBasePermissions.EditListItems)) || li.Fields.GetFieldById(SPBuiltInFieldId.Completed, false) is SPFieldBoolean && li[SPBuiltInFieldId.Completed] != null && (bool) li[SPBuiltInFieldId.Completed])
SPFieldLookup field1 = li.Fields.GetField("TaskGroup", false) as SPFieldLookup;
if (field1 == null || field1.AllowMultipleValues || li["TaskGroup"] == null)
SPFieldLookup field2 = li.Fields.GetField("AssignedTo", false) as SPFieldLookup;
if (field2 == null || field2.AllowMultipleValues)
return new SPFieldLookupValue((string) li["AssignedTo"]).LookupId == user.ID ? ClaimReleaseTaskButton.CRButtonMode.Release : ClaimReleaseTaskButton.CRButtonMode.Hidden;
So, let's sum up when the button will be hidden:
- When form not in Display or Edit mode
- List template not a Tasks (!) list or list item is null
- Item is new or user does not have edit permission
- Item has Complete field and value of this field is
- (!) Item does not have TaskGroup field, or it value is null or type of value Multiple
- (!) Item does not have AssignedTo field or type of value Multiple
- Item claimed by somebody else
Now, let's speek about what does Tasks list mean. SharePoint 2013 has two different tasks list templates:
- List template Tasks with id 107.
It is hidden and cannot be created in UI or in SPD. But it's created when you use option New tasks list in workflow settings page.
- List template Hierarchy with id 171.
This lists is created by standart Tasks app
Claim Release Buttom work only with first type of lists.
How to achive similar funcionality
Main logic of button is pretty simple. When it clicked, private function
DoClaimOrRelease check current
ButtonMode and depending on this value assign to AssignedTo field value of CurrentUser or TaskGroup field.
After that, method do important check: if list item content type is child of workflow task content type then called
SPWorkflowTask.AlterTask(...) method, othewise called
While research, I don't find in
Microsoft.SharePoint.dll code when TaskGroup first time get its value