Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Power Automate: Check if regardingobjectid's type is contact

Posted on by 50

Hello, 

I have a flow that creates a lost opportunity on the background of a additional sales phone call, if our advisors doesn't get any sales that call. 


The flow is triggered on create of phone call activity and checks if a two-option field is checked. When this is checked, the flow creates a new opportunity and closes it as lost. 
I have a couple problems here. The call from ('from') and call to ('to) fields aren't accessible in the trigger. I have two fields to populate - account and contact. These fields should get the regarding value based on which type the regardingobject id has. I have tried running this expression, but I only get an invalid expression error. 

if(triggerOutputs()?['body/_regardingobjectid_value@Microsoft']?['Dynamics']?['CRM']?['lookuplogicalname'] equals 'accounts', triggerOutputs()?['body/_regardingobjectid_value'], false)
This expression checks if the regardingobjectid's type is of Account. If so, add the regardinbobjectid's value, if not null/false (do nothing).
Can anyone see why this expressions is invalid?
Looking forward to any replies that can help me in the right direction.
Best regards, 
Marius
  • Mariusssf Profile Picture
    Mariusssf 50 on at
    RE: Power Automate: Check if regardingobjectid's type is contact
    [quote user="Leah Ju"]

    Hi Mariusssf,

    Not using expression to get regarding type, you can add one ‘Get a row by ID’ step before getting regarding type, which can be more easily.

    1.You can refer following screenshot and steps:

    pastedimage1622450465676v2.png

    2.Result:

    pastedimage1622450508485v3.png

    3.For the sake of testing rigor,i add another one 'compose' after trigger:

    Compose1 has value and compose2 is null.

    pastedimage1622450607202v4.png

    4.Then you can add one condition after compose to do following actions:

    pastedimage1622450774528v5.png

    5.Test:

    pastedimage1622450811132v6.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

    [/quote]

    Hi Leah Ju.

    Thank you for your reply. I do however have to use the expression to solve my issue, I think (?). I'll explain it in more detail.

    My org. has set up contact/account to be contact - private customers and account - business customers. Kinda wrong use of the entities, but that's not what's relevant here. When creating an opportunity there are one lookup field for each of the customer groups, contact and account.

    pastedimage1622539349838v1.png

    Both these are business required, with a script running that once one of those fields contains a customer, the other becomes read-only and is no longer business required. So when adding a new row for opportunity in the Flow both of these are business required.

    pastedimage1622539349839v2.png

    This is why I am trying to use an expression on the fields, something like this: If regarding type == 'account' -> set regarding value, if not do nothing. The same expression will go for the contact field in the flow. The phone call that triggers the flow will always be created from the customer form, so regarding type will always be account or contact. 

    Any suggestions on how to solve this is highly appreciated.

    Regards, 
    Marius

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Power Automate: Check if regardingobjectid's type is contact

    Hi Mariusssf,

    Not using expression to get regarding type, you can add one ‘Get a row by ID’ step before getting regarding type, which can be more easily.

    1.You can refer following screenshot and steps:

    pastedimage1622450465676v2.png

    2.Result:

    pastedimage1622450508485v3.png

    3.For the sake of testing rigor,i add another one 'compose' after trigger:

    Compose1 has value and compose2 is null.

    pastedimage1622450607202v4.png

    4.Then you can add one condition after compose to do following actions:

    pastedimage1622450774528v5.png

    5.Test:

    pastedimage1622450811132v6.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans