AnsweredAssumed Answered

Discard a document if it has child records

Question asked by jorlando79 on Jan 12, 2018
Latest reply on Jan 19, 2018 by jorlando79

I've got a process that wants to delete an Account record in CRM, unless there are Contact records attached to it, but I'm having trouble getting it to work. 

 

The first and most obvious choice - connector call in a decision shape - doesn't work. Accounts can have 0, 1, 2, or dozens of attached Contact records, so this idea consistently fails with the error "Nested connector call returned more than 1 document."

 

My second idea almost works: I have a connector call to retrieve any Contacts records with the relevant parentcustomerid, and that retrieves related documents. But I haven't been able to use the presence of those records to have the process discard / error that document.

 

But: 

If I don't use a Branch to retrieve the contact records, the original document is discarded, which is unacceptable.

If I do use a branch, and set a dynamic document property, any document properties are discarded when the branch switches to #2. 

If I do use a branch, and set a dynamic process property, ALL documents are discarded if ANY document has a child record. 

 

Clearly my ideal solution would be a connector call that can be set to not error if more than one document is returned, or can use a aggregate or summary function. e.g., in SQL, I would just use a clause like WHERE EXISTS (SELECT contactID...), or WHERE (SELECT count(*) cnt...) > 0.

 

How can I sort out these documents so I can process them separately? 

 

microsoft dynamics crm crm dynamics crm dynamics 365 

Outcomes