Automatically submit requests to IT Shop

Hello

I have some 8000 users that I need to automatically request and assign to a business role. The Shelf and product are functioning fine for new users, but I need to migrate some 8000 users to show as having been approved for this product. Any ideas on how I do this?

Regards

Stuart

Parents
  • P.s. you are free to use this solution on your own risk (test first)... 

    I've created a small function that can be used to fire the "CreateITShopOrder customizer method" in bulk

    Public Function CCC_PersonWantsOrg_CreateITShopOrder( _
    	ByVal uidMember As String, _
    	ByVal uidEntitlement As String, _
    	ByVal memberTableName As String) As Boolean
    	
    	Dim f As ISqlFormatter = Session.SqlFormatter
    	
    	Dim tableNames() As String = memberTableName.ToLower.Split({"has", "in"},
    		StringSplitOptions.RemoveEmptyEntries)
    		
        If Not tableNames.Count = 2 Then
    		Throw New Exception("Not a valid membertable")
    	End If
    	
    	If Not Session.Source.Exists(tableNames(0), 
    		f.UidComparison(String.Format("UID_{0}", tableNames(0)), uidMember)) Then
    		
    		Throw New Exception((String.Format("Member {0} not found", uidMember)))
    	End If
    	
    	If Not Session.Source.Exists(tableNames(1), 
    		f.UidComparison(String.Format("UID_{0}", tableNames(1)), uidEntitlement)) Then
    		
    		Throw New Exception((String.Format("Entitlement {0} not found", uidEntitlement)))
    	End If
    	
    	Dim w As String = f.AndRelation( _
    		f.UidComparison(String.Format("UID_{0}", tableNames(0)), uidMember), _
    		f.UidComparison(String.Format("UID_{0}", tableNames(1)), uidEntitlement)
    	)
    	
    	Dim XObjectKeyMembership As String= ""
    	If Not Session.Source.TryGetSingleValue(memberTableName, "XObjectKey", w, XObjectKeyMembership) Then
    		Throw New Exception("Membership not found")
    	End If
    	
    	Try
    		Dim membership As ISingleDbObject = Connection.CreateSingle(New DbObjectKey(XObjectKeyMembership))
    		Dim params As String() = New String() {""}
    		membership.Custom.CallMethod("CreateITShopOrder", params)
    		membership.Save()
    	Catch
            Return False
        End Try
    			
    	Return True
    End Function

    Create custom event on table 'PersonInOrg' eventname = 'CreateITShopOrder'
    Create a simple process in the assignment table in your case "PersonInOrg": ScriptExec
    that triggers on the event: "CreateITShopOrder"

    ScriptName: 'CCC_PersonWantsOrg_CreateITShopOrder'
    Parametervalue0: Value = $UID_Person$
    Parametervalue1: Value = $UID_Org$
    Parametervalue2: Value = 'PersonInOrg'

    Compile...

    Then directly assign all the 8000 users to the b-role 
    Use the Object Browser on the  'PersonInOrg' table to filter and multi-select the 8000 users...
    Then select the tab 'Actions' > 'Events' > 'CreateITShopOrder' 
    After all the jobs are done remove the direct assignments for the 8000 users.
    That should do it!

  • Thanks all, 

    That mostly worked. I just had to get the params right for the CallMethod.

    I needed to add the UID for itShopOrg, then it worked. I still have to flesh out some more, but this is what I have now that works.

    Public Function CCC_PersonWantsOrg_CreateITShopOrder( _
    	ByVal uidMember As String, _
    	ByVal uidEntitlement As String, _
    	ByVal memberTableName As String, _
    	ByVal itShopOrg As String) As Boolean
    	
    	Dim uidItShopOrg As String = CCC_GetUIDFromDescriptiveName( _
    	"O365 - License Group - ZFLC-M365-E3-ARU-BASIC", _
    	"Ident_Org", _
    	"ITShopOrg", _
    	"UID_ITShopOrg")
    	
    	Dim f As ISqlFormatter = Session.SqlFormatter
    	
    	Dim tableNames() As String = memberTableName.ToLower.Split({"has", "in"},
    		StringSplitOptions.RemoveEmptyEntries)
    		
        If Not tableNames.Count = 2 Then
    		Throw New Exception("Not a valid membertable")
    	End If
    	
    	If Not Session.Source.Exists(tableNames(0), 
    		f.UidComparison(String.Format("UID_{0}", tableNames(0)), uidMember)) Then
    		
    		Throw New Exception((String.Format("Member {0} not found", uidMember)))
    	End If
    	
    	If Not Session.Source.Exists(tableNames(1), 
    		f.UidComparison(String.Format("UID_{0}", tableNames(1)), uidEntitlement)) Then
    		
    		Throw New Exception((String.Format("Entitlement {0} not found", uidEntitlement)))
    	End If
    	
    	Dim w As String = f.AndRelation( _
    		f.UidComparison(String.Format("UID_{0}", tableNames(0)), uidMember), _
    		f.UidComparison(String.Format("UID_{0}", tableNames(1)), uidEntitlement)
    	)
    	
    	Dim XObjectKeyMembership As String= ""
    	If Not Session.Source.TryGetSingleValue(memberTableName, "XObjectKey", w, XObjectKeyMembership) Then
    		Throw New Exception("Membership not found")
    	End If
    	
    	Try
    		Dim membership As ISingleDbObject = Connection.CreateSingle(New DbObjectKey(XObjectKeyMembership))
    				
    		membership.custom.CallMethod("CreateITShopOrder", uidItShopOrg, uidMember, "")
    		membership.Save()
    	Catch ex As Exception
            Throw New Exception(ViException.ErrorString(ex))
    		Return False
        End Try
    			
    	Return True
    End Function

Reply
  • Thanks all, 

    That mostly worked. I just had to get the params right for the CallMethod.

    I needed to add the UID for itShopOrg, then it worked. I still have to flesh out some more, but this is what I have now that works.

    Public Function CCC_PersonWantsOrg_CreateITShopOrder( _
    	ByVal uidMember As String, _
    	ByVal uidEntitlement As String, _
    	ByVal memberTableName As String, _
    	ByVal itShopOrg As String) As Boolean
    	
    	Dim uidItShopOrg As String = CCC_GetUIDFromDescriptiveName( _
    	"O365 - License Group - ZFLC-M365-E3-ARU-BASIC", _
    	"Ident_Org", _
    	"ITShopOrg", _
    	"UID_ITShopOrg")
    	
    	Dim f As ISqlFormatter = Session.SqlFormatter
    	
    	Dim tableNames() As String = memberTableName.ToLower.Split({"has", "in"},
    		StringSplitOptions.RemoveEmptyEntries)
    		
        If Not tableNames.Count = 2 Then
    		Throw New Exception("Not a valid membertable")
    	End If
    	
    	If Not Session.Source.Exists(tableNames(0), 
    		f.UidComparison(String.Format("UID_{0}", tableNames(0)), uidMember)) Then
    		
    		Throw New Exception((String.Format("Member {0} not found", uidMember)))
    	End If
    	
    	If Not Session.Source.Exists(tableNames(1), 
    		f.UidComparison(String.Format("UID_{0}", tableNames(1)), uidEntitlement)) Then
    		
    		Throw New Exception((String.Format("Entitlement {0} not found", uidEntitlement)))
    	End If
    	
    	Dim w As String = f.AndRelation( _
    		f.UidComparison(String.Format("UID_{0}", tableNames(0)), uidMember), _
    		f.UidComparison(String.Format("UID_{0}", tableNames(1)), uidEntitlement)
    	)
    	
    	Dim XObjectKeyMembership As String= ""
    	If Not Session.Source.TryGetSingleValue(memberTableName, "XObjectKey", w, XObjectKeyMembership) Then
    		Throw New Exception("Membership not found")
    	End If
    	
    	Try
    		Dim membership As ISingleDbObject = Connection.CreateSingle(New DbObjectKey(XObjectKeyMembership))
    				
    		membership.custom.CallMethod("CreateITShopOrder", uidItShopOrg, uidMember, "")
    		membership.Save()
    	Catch ex As Exception
            Throw New Exception(ViException.ErrorString(ex))
    		Return False
        End Try
    			
    	Return True
    End Function

Children
No Data