- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to restrict item rollbacks to a certain group of users on items with a specific custom item category. When I execute an item rollback with the code below, I get:
- Roll Back Lifecycle State Change dialog box and click YES.
- Get an error dialog that states, “Object reference not set to an instance of an object” and click OK.
- My message box displays with “Has ASME Privilege: False” and I click OK.
- Roll Back Lifecycle State Change Failed dialog box is displayed listing the restriction.
However, if I comment out the dim statement and the second message box statement and uncomment the first message box statement, my message box with the item ID will display and then the Roll Back Lifecycle State Change Failed dialog box but no “Object reference” error message. It seems like I can’t call any custom sub or function inside the ItemRollbackCheck Sub without getting the error. I need to get a Boolean value in if the current user is part of an approved group and I need a way to get the current item category. I can get the item ID easy enough within the sub but can’t do anything with it.
Public Sub OnLoad() Implements Autodesk.Connectivity.WebServices.IWebServiceExtension.OnLoad
AddHandler ItemService.ItemRollbackLifeCycleStatesEvents.GetRestrictions, AddressOf ItemRollbackCheck
End Sub
Private Sub ItemRollbackCheck(ByVal sender As Object, ByVal e As ItemRollbackLifeCycleStateCommandEventArgs)
Try
Dim approved As Boolean = HasASMEPrivilege(approvedgroup)
'MessageBox.Show("ItemId: " & e.ItemIterationId.ToString) 'this works
MessageBox.Show("Has ASME Privilege: " & approved) ' errors first, then displays this message box
Dim restrict As ExtensionRestriction = New ExtensionRestriction(e.ItemIterationId.ToString, "No Permission")
e.AddRestriction(restrict)
Catch ex As Exception
'MessageBox.Show(ex.Message)
End Try
End Sub
Solved! Go to Solution.

