This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cancel IT Shop Order are not working from the Script Component

Dear All,

We are trying to abort or Unsubscribe IT Shop orders for a given SAP Account. Attached my code, it is working fine when i test the script directly calling from Script Debugger but it is not working when we call same script with same attributes from Script Component.

Any idea

Thank you,

Deepu Chandran

Public Function CCC_SAP_AbortITShopOrders (ByVal UIDSAPUser As String) As String		
	
	Dim f As ISqlFormatter = Session.SqlFormatter		
	Dim dbAccount As IEntity
    dbAccount = Session.Source.Get("SAPUser", UIDSAPUser)
	Dim UIDPerson As String = dbAccount.GetValue("UID_Person").String
	
	Dim dbSAPUserRole As IColDbObject = Connection.CreateCol("SAPUserInSAPRole")
    dbSAPUserRole.Prototype.WhereClause = f.Comparison("UID_SAPUser", UIDSAPUser, ValType.String, CompareOperator.Equal)
    dbSAPUserRole.Load()	
    
	For Each colElement As IColElem In dbSAPUserRole			
		Dim UIDPersonWantsOrg = Connection.GetSingleProperty("PersonWantsOrg","UID_PersonWantsOrg",f.AndRelation(f.Comparison("UID_PersonOrdered", UIDPerson, ValType.String, CompareOperator.Equal) _
                                    ,f.Comparison("ObjectKeyOrdered",colElement.GetValue("ObjectKeySAPRole").String,ValType.String, CompareOperator.Equal)))
		If Not String.IsNullOrWhiteSpace(UIDPersonWantsOrg) Then				
			Dim dbPWO As ISingleDbObject = Connection.CreateSingle("PersonWantsOrg",UIDPersonWantsOrg)	    		
    		dbPWO.Load()
			If String.Equals(dbPWO.GetValue("OrderState").String, "Waiting") OrElse String.Equals(dbPWO.GetValue("OrderState").String, "OrderProduct") Then
				Dim Params As String() = New String() {UIDPerson,"Account is not used for long time"} 
	            dbPWO.Custom.CallMethod("CancelOrder", Params)
	            dbPWO.Save()
			ElseIf String.Equals(dbPWO.GetValue("OrderState").String, "Assigned") Then
				Dim Params As String() = New String() {UIDPerson,"Account is not used for long time"} 
	            dbPWO.Custom.CallMethod("Unsubscribe",Params)
	            dbPWO.Save()			
	        End If			
		End If		
	Next		
    Return String.Empty
End Function

Parents Reply Children
  • Thank you for the Quick message..

    No error message, the status is not changing

  • I assume that your script is unable to find a UIDPersonWantsOrg as this would explain that your script is doing nothing. I would turn on debug logging or SQL logging and check the executed statements if the results are as expected.

  • Hi Markus,

    I have fixed the issue, the issue was there are many request which is unsubscribed for the same user and same role present in PersonWantsOrg Table.

    Dim strINClause As String() = {"Assigned","Waiting","OrderProduct"}
    Dim UIDPersonWantsOrg = Connection.GetSingleProperty("PersonWantsOrg","UID_PersonWantsOrg",f.AndRelation(f.Comparison("UID_PersonOrdered", UIDPerson, ValType.String, CompareOperator.Equal) _
                                        ,f.Comparison("ObjectKeyOrdered",colElement.GetValue("ObjectKeySAPRole").String,ValType.String, CompareOperator.Equal) _
    									,f.InClause("OrderState",ValType.String,strINClause)))