Call method cancel order for a PWO from inside a Deferred Operation

Hi all, community

I was wondering if it is possible to call the method CancelOrder for a PersonWantsOrg from inside a Deferred Operation. I have tried, of course, and I was successful in create the deferred operation but after it run, the pwo was still there in status Assigned. I wasn’t give back with any error or else. It simply executed the deferred but no output.

The same pwo was correctly processed by the same code outside the Deferred Operation, and this makes me think the code is ok. By the way, I use the ISIngleDBObject.

Can someone please give me advices?

Thanks in advance.

A

Parents
  • I think it might be the reason that you are using the old ISingleDBObject interface.

    Try to use the current IEntity interfaces for handling your object and calling the method,

    Sample: Using a Deferred Block for IEntities

    ' Create a new deferred block for a specified point in time.
    Using New VI.DB.DeferredOperations.DeferredBlock(Session, DateTime.UtcNow.AddDays(30), "Optional description for the deferred operation")
    ' Operations done here are done deferred

    ' Call a customizer method on entity dbEntity
    dbEntity.CallMethod("MakeDecision", uidPersonHead, bDecision, strReason)

    If dbEntity.GetMethod(Session, "MakeDecision", uidPersonHead, bDecision, strReason)?.Behavior.HasFlagFast(MethodBehavior.SaveRequired) Then
    ' Save to execute the method
    dbEntity.Save(Session)
    End If
    End Using
  • Markus, thanks, it worked like a charm.

    After I switched to IEntity everything seems to work as expected.

    Just one more thing… . The scenario is that a user was given a form (a custom form designed by us) in which he can create or cancel (abort) some pwo as deferred operation.

    I tried both to create one deferred block and add all new pwos there, and create a single deferred operation block for each new pwo. But independently from how many deferred block I create, the FIRST and only the first deferred operation, when executed, went in error. The other 4 pwos (I have tried to deferring create 5 pwos) are instead created without any problems. The process at this point tryes again and after something like 10 minutes the pwo is successfully created.

    On the jobserver log I found this:

    810023] Error running statement: insert into PersonWantsOrg (CustomProperty06, DisplayOrg, DisplayOrgParent, DisplayOrgParentOfParent, DisplayPersonInserted, DisplayPersonOrdered, GenProcID, ObjectKeyFinal, ObjectKeyOrdered, OrderDate, OrderReason, OrderState, UID_ITShopOrgFinal, UID_Org, UID_OrgParent, UID_OrgParentOfParent, UID_PersonInserted, UID_PersonOrdered, UID_PersonWantsOrg, UID_QERWorkingMethod, UiOrderState, xdateinserted, xuserinserted, xdateupdated, xuserupdated, xobjectkey) values (N'xxxxxxxxx’, N’Product name’, N’Shelf name, N'shopname', N’xxxxxxxxxx', N'xxxxxxxx, yyyyyyyyyyyy, 'FE184DA2-365A-430A-B437-E6B04E40D684', '<Key><T>ESet</T><P>e5550234-658a-4bb1-9824-a3ad17f8066a</P></Key>', '<Key><T>ESet</T><P>e5550234-658a-4bb1-9824-a3ad17f8066a</P></Key>', '2023-11-03 10:15:27.033', N'Requested by xxxxxxxxx. Ticket xxxxxxx: xxxxxx, N'OrderProduct', 'AACA11B6-940E-4DAD-9F5B-1F825CF3E973', 'AACA11B6-940E-4DAD-9F5B-1F825CF3E973', '36d3549a-89d6-4094-9dbf-0fb6be4719df', '022427ba-adfd-4c4f-8821-b50654371d4d', '3f437eaa-75e5-4e88-b1f1-dd77e83213d3', '969da1de-952a-4489-a271-17c6a08d8fef', '7a6598e3-3b46-41d2-b710-c60ba07728f5', '74BDBB75-26DE-4DB6-B57E-29FAB562DB1E', N'OrderProduct', GetUTCDate(), N'xxxxxxxxx’, GetUTCDate(), N’xxxxxxxxxx’, '<Key><T>PersonWantsOrg</T><P>7a6598e3-3b46-41d2-b710-c60ba07728f5</P></Key>')

    [810143] Database error 2627: detected in (SRV=WT0BV-OIAP001, DB=OneIdentity911) Procedure QER_TIPersonWantsOrg, Line 10
        [810143] Database error 2627: Violation of PRIMARY KEY constraint 'PK__DialogPr__2B66FD777B7C4559'. Cannot insert duplicate key in object 'dbo.DialogProcess'. The duplicate key value is (FE184DA2-365A-430A-B437-E6B04E40D684).

    After this, the pwo is still created but at the next process try.

    Can you give me some clues? Which could be the problem? Is not that painful as at the end the pwo is created, but we cannot understand the reason the first deferred always go broke.

     

    Thanks again, a lot

    a

  • I might have missed that but we are talking about what version of OneIM?

  • 9.1 and i have no ideas about the previous as i implemented this only on 9.1

  • Can you check if the process steps (the 5 mentioned) all have the same processId (GenProcID)?

    And please check if the code of the database trigger "QER_TIPersonWantsOrg" at the table PersonWantsOrg contains a code sequence like this

    where not exists (select top 1 1 from Dialogprocess where GenProcID = p.Parameter1)

  • Markus, I run again the test for the creation of pwos. But this time only the first was created at the first run while the other 4 were delayed.

    The GenProcId is the same for all 5 deferred, and yes I found where “not exists (select top 1 1 from Dialogprocess where GenProcID = p.Parameter1)”  in the triggers of PersonWantsOrg

     

    I did not have problems deleting or cancelling the pwo into a block of deferred

  • I am asking around internally. But the issue seems to be related to your GenProcIds.

  • thank you so much. let me know if you have some news

  • We discussed some ideas internally but did not find a definitive answer or solution. But you can address this issue with support which would allow to dig further into this issue.

  • Thank you Markus, your commitment is always precious and reliable.

    But please let me dig a little bit in this subject. When I buy a pwo from inside a deferred block, the system let me do that even if the person is not in the itshop where the product is published. Only once the deferred is executed I got the exception so I was wondering if there is a robust way to check if the pwo I’m about to submit is legitimate and then submit it as deferred.

    As usual thanks in advance

    a

  • With the help of my awesome colleague (thanks HB!) .....

    To answer the question "is this PWO valid", you would have to make so many checks that are distributed across format rules and customizers that I would recommend to

    • Commit the e1ntity in an open transaction.
    • This is either successful or not
    • The transaction must then be rolled back.
    • Then you should put an equally populated entity in a DeferredOperation. (not the same one that was used for the test before - that won't work

    If only the authorization is relevant, the statement returns a result if the person can order it:

    select * from QER_FTPWOOrderPerson('uid_person','uid_itshoporgpr', 'uid_accproduct',
    null, --validfrom
    null --validuntil
    )

  • Markus, thanks it worked as you said! Again, thank you.

    a

Reply Children
No Data