cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
oml
Helper II
Helper II

How to check if Customer field is of type Account or Contact

Hi,

 

I have been looking around a bit for my question but haven't had any luck so far.

 

In my head, this should be pretty straightforward but is giving me trouble...

 

So I have a Flow where I need to set a variable depending on whether the Customer field is a type of Account or Contact.

I can't get my condition to work properly - it's returning false every run. And I'm 100% sure that the case has an "Account" in the Customer field.

 

I have tried the following conditions:

Customer (Value)is equal toAccount
Customer (Value)is equal toaccount
Customer (Value)is equal toaccounts
Customer (Type)is equal toAccount
Customer (Type)is equal toaccount
Customer (Type)is equal toaccounts

 

Here is a screenshot of my flow.

2020-12-16 12_08_51-Window.png


Can someone please explain to me what I'm doing wrong?

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

That explains a lot! 😁

What happens if you put this expression in the compose action:

triggerOutputs()?['body/_customerid_type']

That may not be right, a partial guess as you didn't post your complete output of the trigger action. But might work.

View solution in original post

10 REPLIES 10
Paulie78
Super User
Super User

Go into your run history, check the output of the trigger step "When a record is created, updated or deleted". From that you will be able to find the exact property and value that you need to be matching. If you find that bit and post the result here it will be easy to make your condition.

Hi,

Thanks for reply.

 

Here is the case body output:

case body.png

 

and here is how I would set the condition:

 

condition.pngfinal condition.png

 

 

Paulie78
Super User
Super User

based on your screenshot you would expect "accounts" to be an equal match. Try creating a compose step before the condition which just outputs "Customer (Type)" from the dynamic content an call it "customerType". Then you will be able to use that value on the left side of the condition, and also see what it was set to before the condition takes place. The other thing you might try on the right side of the condition is an expression of:

string('accounts')

and see if that produces a different result.

 

Thanks for the quick reply.

 

I have done the following without any luck:

compose.png

 

But I'm not too familiar with the "compose" action so I might be misunderstanding something.. 🙂

Paulie78
Super User
Super User

You did it correctly, when you look in the run history, what is output of the compose? Did you also try what I mentioned about and put the expression:

string('accounts')

On the right side of the condition?

This is my compose output:

compose output.png

And when I Click to download it opens up a new "about:blank" webpage. All blank. Really weird..

 

And yes, I also tried with the string('accounts')

Paulie78
Super User
Super User

That explains a lot! 😁

What happens if you put this expression in the compose action:

triggerOutputs()?['body/_customerid_type']

That may not be right, a partial guess as you didn't post your complete output of the trigger action. But might work.

oml
Helper II
Helper II

Thank you very much @Paulie78 !

 

That expression did the trick!

 

Would I be able to use that expression directly in the condition? Or do I need the compose step action?

Paulie78
Super User
Super User

You do not need the compose step, that was just for troubleshooting/visibility purposes, feel free to delete it and put the expression in the condition.

Shaboo992
Frequent Visitor

Find the way to get the customer record for an entity.

 

Example: I want to get the contact - customer lookup this can be account or contact else blank. 

Step 1 : Get the contact record by contact id and select "_parentcustomerid_value" to return at least, can be ignored that will give full list of fields

 

Step 2 : Run the flow take the output of the flow action from above step and copy body on to Parse Json.

content use out put from get contact details - body & generate sample.

Shaboo992_0-1639071118352.png

 

 

Step 3: Important step to identify customer lookup logical name - Compose date oprator user - body('Parse_JSON')?['_parentcustomerid_value@Microsoft.Dynamics.CRM.lookuplogicalname that returns lookup logical name in case if you want get the out put as null use coalesce it returns value if blank coalesce(body('Parse_JSON')?['_parentcustomerid_value@Microsoft.Dynamics.CRM.lookuplogicalname'],'none')

Shaboo992_1-1639071118211.png

 

 

 

Step 4: Use switch statement and use output of the compose to branch the contact or account else default to get the record values

 

Step 5: Get contact or account details

 

 

Shaboo992_2-1639071118822.png

 

 

If you find useful please thumbs up.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,856)