How to programmatically add a deferred operation to delete PersonHasQERResource?

We have a use case to to automatically remove a Resource assignment a week after it was assigned.  I have tried to use a deferred block similar to this forum:  RE: Create a Deferred Event Generation Operation from a Script but I can't find an option to create a deferred operation to "Delete" an entry in the PersonHasQERResource.  Any thoughts if there are ways to do this?  Thanks in advance!

  • You just load the object and delete it then in the deferred operation block.

    A sample loading the entity to remove (PersonHasQERResource) via the XObjectKey would look like this:

    Dim dbEntity As IEntity = Session.Source.Get(New DbObjectKey(myXObjectKey), EntityLoadType.Default)
    
    ' 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
        Using uow = Session.StartUnitOfWork()
            ' Delete the entity immediately
            dbEntity.MarkForDeletionWithoutDelay()
    
            ' put the object in the unit of work
            uow.Put(dbEntity)
            uow.Commit()
        End Using
    End Using
    

  • Got it, this is perfect Markus!  Thanks as always.... You're the man!