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