prevent UNSAccountBInGroupB delete event

Hi community

Please, help with this very old topic, for which I cannot find a solution.

I’m working on version 8.14.

The problem is to prevent the execution of the event UNSAccountBInGroupB when a custom synchronization from target system to OI deletes the record.

Let me be clear: when I run a full synchronization, in order to get the data from the target system, sometimes I need to remove some UNSAccountBinGroupB. But when I do that (I’ve tried in several ways, from using ISingleDbObject to using entity, passing through deepdelete or simply putting XOrigin = 0 – when I can- or XIsInEffect = 0) , even if I set variable Connection.Variables("FULLSYNC") = True, the event Delete is always fired and the process is started.

How can I prevent this, in order to do not synchronize back the target system?

 

Thank you in advance

Alberto

Parents
  • You cannot prevent the event, but in your process listening to event but a check into the generation condition that it should not run if a fullsync is running. A sample would the following, assuming that you are setting the FULLSYNC variable during your sync.

    Value = Not CBool(Connection.Variables("FULLSYNC"))

  • Hi Markus and thank you as usual

    I’m wide aware I cannot prevent the event itself, I meant I would like to prevent the process to be fired.

    And obviously I was working on generating conditions, but as I mentioned, even if I set the FullSync variables (as Connection.Variables("FULLSYNC") = True or as Variables.Put("FULLSYNC", True) in the “main” synchronization script (from Target System to One Identity), before removing the UNSAccountBInGRoupB,  the process is still fired.

    There is no way I can “pass” the Fulsync value to the generation condition.

    I have also tried to not remove the FullSync variable at the end of the main sync script (Variables.Remove("FULLSYNC")) but nothing works.

    So I’m sorry but I don’t think this is the solution. For your info, I tried something that works for the “Assign” event: I played around with XIsInEffect and/or XOrigin, but still anything was useful.

     

    Let me know please.

     

    A

  • What about using the Remove event instead of Delete?

  • Markus, maybe I do not understand

    The VI_UnsAccountInGroup_Generic_Del is, in my version of OI, already bonded to the event REMOVE (sorry, I supposed it was to DELETE as the process name ends with “Del”)

    For this reason I cannot understand what you mean when you say “What about using the Remove event instead of Delete?”

     

    Currenty I’m doing the followings:

    current_group.PutValue("XOrigin", 0)                                                                       

    current_group.PutValue("XIsInEffect", 0)

    current_group.Save()

     

    or

    Dim dd As DeepDelete = New DeepDelete(current_group)

    dd.Execute()

     

    but I have also tried the same with entity, with uow, with everything I could, but that Remove event still fires the process.

    So, what next Blush ??

     

    A

Reply
  • Markus, maybe I do not understand

    The VI_UnsAccountInGroup_Generic_Del is, in my version of OI, already bonded to the event REMOVE (sorry, I supposed it was to DELETE as the process name ends with “Del”)

    For this reason I cannot understand what you mean when you say “What about using the Remove event instead of Delete?”

     

    Currenty I’m doing the followings:

    current_group.PutValue("XOrigin", 0)                                                                       

    current_group.PutValue("XIsInEffect", 0)

    current_group.Save()

     

    or

    Dim dd As DeepDelete = New DeepDelete(current_group)

    dd.Execute()

     

    but I have also tried the same with entity, with uow, with everything I could, but that Remove event still fires the process.

    So, what next Blush ??

     

    A

Children
  • I am sorry, but you never mentioned the usage of VI_UnsAccountInGroup_Generic_Del in your post, so I assumed a custom process. My bad.

    Allow me one question, do you have a DeleteDelay configured at UNSAccountBInUNSGroupB?

    What you can try is:

    • A) Add the condition "AndAlso NOT (CBool(Connection.Variables("XORIGINEMPTY")))" to your gen.condition
    • B) Delete the assignment with the entity metho .MarkForDeletionWithoutDelay

    Sample Script:

    Public Sub DBObjects_Delete()
    
        ' Create a collection of Person objects
        Dim queryPersons = Query.From("Person") _
                              .Where(Function(t) t.Column("Lastname") = "Einstein") _
                              .SelectAll()
    
        Dim persons = Session.Source.GetCollection(queryPersons, EntityCollectionLoadType.Bulk)
    
        Using uow = Session.StartUnitOfWork()
    
            ' Walk through the list of all persons
            For Each person As IEntity In persons
    
                ' Mark for deletion
                person.MarkForDeletionWithoutDelay
    
                ' put the object in the unit of work
                uow.Put(person)
            Next
    
            ' All person objects will be saved here!
            uow.Commit()
        End Using
    
    End Sub

  • Markus, as usual, you solve the day and probably the weekend :-)

    I did what you suggested and now the event is fired but the process is not, thus it is perfect!

    Just one thing.

    As I have already the object group_level.Existing_UNSAccountBInGroupB of type < UNSAccountBInUNSGroupB>, I simply call the entity out of it without performing other query. It seems it works, but please, if you see some critical issues, please tell me:

     

    Using uow = Session.StartUnitOfWork(procId)

    Dim entity_group As IEntity = group_level.Existing_UNSAccountBInGroupB.Entity()

                   entity_group.MarkForDeletionWithoutDelay()

                   uow.Put(entity_group)

                   uow.Commit()

    End Using

     

    THANK YOU as usual

     

    A

  • Glad, you got it solved. I can see no issue. My code was just the complete sample from the SDK\ScriptSamples folder, updated with the MarkForDeletionWithoutDelay method.

    Enjoy your weekend ;-)