Powershell connector remove event not working

Hello,

I'm working on powershell connector for CRM Dynamics 365 and I stumbled across specific problem.

I want to remove acount roles membership (UNSAccountB IN UNSGroupB) and wrote PS method for it. I created workflow in synchronization editor and process in designer that triggers on event "REMOVE".

I tested the method via Powershell ISE and it works, also if I browse memberships via synchronization Editor and try to delete it works fine.

When I remove membership in Manager and event "REMOVE" triggers, then workflow launches as it should, however the record doesn't get deleted. I'm also using debbuger in PS method and noticed my delete method doesn't get called when executed via Manager event.

I tryed creating two different workflows (one for adding memberships and one for deleting) and It doesn't work. It's almost as if AdHocProjection is not recognising the record is marked as Deleted.

I can't figure out what the problem is, any ideas?

  • Hi Barry,

    Thank you for fast reply, unfortunately I can't access the link ("the page you've requested no longer exists")

  • Someone had a similar question and here the answers from this thread:

    Answer 1


    Hi ,

    not really knowing what you have configured let me mention two main things having to do with Projector engine:
    1.) Job chain having to do with an AdHocProjection should process always a script (Pre-script) to check the registered operation for the current object and the the existence of a sync shell. If there is no eligible DPRObjectoperation or sychronization project the job chain will not be generated.
    2.) Starting an AdHocProjection job the Projector engine will check the given sychronization project for a provisionig workflow step having the correct schema type. If a workflow step has been found the Projector engine checks the connected mapping if there is any mapping rule that references a changed property.
    If none of given changed properties is used in a mapping rule the Projection ends without any action.

    In addition, you need to know the System browser hands over all properties of the current object to the projection job. In case of using OneIM Manager on update operation is generated a "patch" (xml structure) having key properties and changed properties only.

    So I could think of two mistakes:
    * the job chain is generated on wrong object ("UNSAccount" or "UNSAccountInUNSGroupB" instead of "UNSGroupB") and the mapping checked by the Projector engine has not an eligible rule for the changed property
    OR
    * there is a property you have to hand over additionally to projection job which has not been changed, may be the name of the group (you may do this using the job parameter "ForceSyncOf")

    Answer 2

    Hi,
    thanks for the help.
    after contacting support seems like updating the CausingEntityPatch has done the trick with something along these lines

    If EventName.ToUpper = "ASSIGN" Then
        Value = DPR_WrapObjectForProjection(Entity)
    Else
        Dim epatch As String = DPR_WrapObjectForProjection(Entity)
        Value = epatch.ToString.Replace("<Data State=""Loaded, PermissionBased"" />", "<Data State=""Loaded, Deleted, PermissionBased, ToDeletePhysical"" />")
    End If

  • Hi Markus,

    I tried the solution you listed, but it didn't fix the problem for me. The right process step gets triggered, but synchronization editor still doesn't recognise the record as deleted.

    I also tryed adding ForceSync in Pre-script generating of the proces:

    values("ForceSyncOf") = $UID_UNSAccountB$

    And then calling the value in CausingEntityPatch on the process step and that also doesn't fix the problem.

    Any other suggestions?