Skip to main content
Planview Customer Success Center

API UpdateRolesAndFeatures method does not add/remove features (2012)

SYMPTOMS:
Trying to use the COM API to add a Feature for user with the 'SR-Base User' role with a FeatureCode = 'BUL'.

The following code for a resourceid  already has the BUL feature:

Private oCon As New ApiConnection
Private mRes As New ApiResource
mRes.CPConnection = oCon
strresourceid = "D6B0858F-1DBC-49B2-8D9B-1D15A75977BA"
strRole =""
strFeature = ""
iRet = mRes.GetById(strResourceId)
mRes.BypassMetadataCheck = CPMetadataCheck.BypassAll
iRet = mRes.UpdateRolesAndFeatures(strResourceId, strRole, strFeature)

The iRet returns 0 for each call, the roles are removed for the resourceid but the feature "BUL" (Base User) is not removed.

REASON:
Business rules have changed with the API to reflect those in the UI.

RESOLUTION:
In order to add or remove a role or feature to or from resource, the method add/remove should be used.
Example: 


APIResource.ResourceRoles.Add("roleId");
This adds the role to resource

APIResource.ResourceRoles.Remove("roleId");
This will remove the role from resource. Note: the roleID should be in lower case to get removed
APIResource.ResourceFeatures.Add("featureCode");
This will add a feature to resource

APIResource.ResourceFeatures.Remove("featureCode");
This will remove the feature from resource


Additonally the BUL feature cannot be added or removed through an update method. It is automatically added when licensed is set = 1 and resourcetype = enterprise