Display “Customer” name instead of GUID in Power Apps

It’s been a long time since I wrote a blog post , It’s been a great year for me 😀 and I wish the same for you as well. I worked on two implementation working  with Dynamics 365 Finance and Operation team to implement complete Dynamics 365 project.

Key highlight of the project was the integration between Customer Engagement and Finance and operation using CDS (Prospect to Cash ). It works like a charm saving valuable time and cost for customer. If you are thinking ,”how can it work like  charm !” 😀 well we spend most of our late night figuring out the issue as well , but it all worked out in the end.

So, now I am engaged in Power Apps ( little late to the party though :p) , I came across a scenario where Power App was needed to enable sales person to sell his products to customer.

This isn’t walk through about how to create a power App , there are  lots of example already (may be in future with a full app).But I was stuck in simple yet complicated situation (when google results fails , you are in complicated relationship my friend ).

Problem

I was working with power apps to display a custom entity data which has Customer Type field. When I created app using “Start with data” template, the customer and other lookup filed display value as GUID instead of “Name”.

Annotation 2019-07-01 154819

Solution

I looked online but didn’t find any solution, since its a customer type field, data can be from either of the entity, so adding new data source solution doesn’t quit work for customer type field ,for other it worked as it should be. (as suggested in the this link https://www.inogic.com/blog/2018/07/working-on-lookup-field-of-dynamics-365-in-powerapps/),

So what i did ? I left the office for late night motorcycle ride with my friends 😛  to start over tomorrow.

The logic was simple

 if  

This isn't returning a value 

LookUp(Contacts,contactid in Parent .Default,fullname)

Then Do this 

LookUp(Accounts, accountid in Parent .Default,name)

 

so after few Ctrl+Z , Delete , the correct way of doing it is

 

If (
    'Customer Type' = "contacts",
    LookUp(
        Contacts,
        contactid in Parent.Default,
        fullname
    ),
    'Customer Type' = "accounts",
    LookUp(
        Accounts,
        accountid in Parent.Default,
        name
    )
)

 

So it is very simple to understand , first this function is checking type of customer record and then based on the output it is executing the appropriate LookUp function.

That’s all folks.. Enjoy your Spider-man Far from home this weekend 😀

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: