I'm writing a script (VBScript) to create/update SystemUser in the CRM by importing the required information from one of our SQL table. Everything works fine but the update of the BusinessUnitId field.
The problem is the CRM restrict the ability to do so for disabled user. And by default all my users are disabled (they serve more as contacts than user, only a few of them are actually enabled). My question is fairly simple: how do I check if the user is enabled or not ?
StateCode and StatusCode are only made to set a user to enabled or disabled. IsDisabled field in the Systemuser CRM table seems unreadable (I get an key does not exist error if I try to read from it).
I'm really stuck here. Any ideas ?
Thank you
Update 3/11/2014 (Code as requested)
Try 1 - Always Return True even when it should be False
If (user_new.Contains("isdisabled") And user_new.GetAttributeValue(Of Boolean)("isdisabled") = False) Then
Console.WriteLine("ENABLED")
Else
Console.WriteLine("DISABLED")
End If
Try 2 - Key does not exist
If (user_new.Attributes("isdisabled") = False) Then
Console.WriteLine("ENABLED")
Else
Console.WriteLine("DISABLED")
End If
Try 3 - Key does not exist
If (user_new.FormattedValues("isdisabled").ToString() = 0) Then
Console.WriteLine("ENABLED")
Else
Console.WriteLine("DISABLED")
End If
BusinessUnit
, Equipment
, Organization
, Resource
and SystemUser
all use the IsDisabled
field instead of the standard StateCode
and StatusCode
. It should be stored as a boolean. Make sure that you include it in your ColumnSet when you retrieve the SystemUser from CRM