Monday, July 14, 2008

Set the State/Status of A Custom Entity in CRM 4.0 in VB

In addition to Catherine Eibner's post below on setting the satus of a custom entity in C#, I'd like to help the more logical programmers out there by posting the VB version..

Catherine Eibner: Set the State/Status of A Custom Entity in CRM 4.0


'This will set a task as complete
Dim SetTaskState As New SetStateTaskRequest
SetTaskState.EntityId = MyTaskGUID.Value
SetTaskState.TaskState = TaskState.Completed
SetTaskState.TaskStatus = -1
CrmSvc.Execute(SetTaskState)

'This will deactivate a custom entity
'Note the SetStateNew_customentityRequest while the name of the
'entity is new_customentity.
Dim SetCustEntityState As New SetStateNew_customentityRequest
SetCustEntityState.EntityId = MyCustomEntityGUID.Value
'Note New_customentityState when entity name is new_customentity
SetCustEntityState.New_customentityState = New_customentityState.Inactive
SetCustEntityState.New_customentityStatus = -1
CrmSvc.Execute(SetCustEntityState)

No comments: