13 Nov’17

Dynamics 365, EnterpriseHow to Connect with Dynamics 365 and use Lookup Field of Dynamics CRM in PowerApps.

Introduction:

This blog explains how to Connect with Dynamics 365 and use Lookup Field of Dynamics CRM in PowerApps.

Steps for Creating Connection to Dynamics 365:

  1. Go to https://web.powerapps.com
  2. Create a new Connection with Dynamics 365.
  3. Click  on  New Connection and search for Dynamics 365.
  4. Select Dynamics 365  and click on  Create.
  5. Enter the Credentials for the Connection.

Steps for Creating an App:

  1. Go to App and Click on Create an App.
  2. Under Start with your data select Phone Layout for Dynamics 365.
  3. Now Select Connection and choose a  dataset from that Connection.
  4. Select the Entity from the list.
  5. Click on Connect.
  6. PowerApps will create Browse, Details and Edit screen for you.
    • Browse Screen: You can search for the record and see all the records which are created.
    • Detail Screen: It gives details of record which is selected in Browse Screen.
    • Edit Screen: You can create or update the records from this Screen.

Important : The current Dynamics 365 connector does not support lookup or option set data types. so we’ll demonstrate how we worked around the lookup limitation.

Example: For contact entity there is Lookup field for accounts.To use Lookup Datatype in contacts for account you must add account entity also in PowerApps.

Steps for adding Account Entity:

  1. Go to View -> Data Source -> Select the Connection
  2. Choose Dataset->Select Account Entity ->Connect.

Now Make changes on each screen so that you get account name instead of GUID of account entity.

Browse Screen:

Select the field in which you want to display account name. Under Text Property of that field write :

LookUp(Accounts , accountid = ThisItem._parentcustomerid_value , name)

Now it will return the name of Account instead of GUID.

Detail Screen:

Select the field in which you want to display account name. Under Text Property of that field write :

LookUp(Accounts, accountid = ThisItem._parentcustomerid_value ,  name)

Now it will return the name of Account instead of GUID.

Edit Screen:

Steps:

  1. Create a new Blank screen name it as account lookup.
  2. Add Gallery control inside Blank Screen and set its items property to accounts.

  3. Select the next arrow and set its OnSelect property to :

     ClearCollect( Selectedaccount, { Account: Gallery1.Selected } ); Back() 

  4. Now Go back to Edit Screen Select  the Data Card of Company Name and Go on Advanced Properties and Unlock the Data Card.

  5. After Unlocking the Data Card Add search icon inside the Data Card.

  6. Now select that Data Card of Company Name and set its Default value to:

    If(IsBlank(First(Selectedaccount).Account.accountid ) , ThisItem._parentcustomerid_value , First(Selectedaccount).Account.accountid )

  7. Select the Data Card value of Company Name and set its Default value to:

    LookUp(Accounts, accountid= ThisItem._parentcustomerid_value , name)

  8. Select the Data Card and set its update Property to:

    Gallery1.Selected.accountid

  9. Select the search icon and set its OnSelect property to:

    Navigate(‘account lookup’,ScreenTransition.Fade)

  10. Select the Data Card of Company Name Type field and set its Default value to: “accounts”

  11. Select the form and set its OnSuccess Property to:

    Clear(Selectedaccount);Back()

  12. Select the Cancel icon and set its OnSelect Property to:

    Clear(Selectedaccount);ResetForm(EditForm1);Back()

Written by

Vaishali Vyas

Trainee Software Engineer

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Commands to Import .bacpac file to D3FOE SQL Server

    14 May’ 2018

    Introduction: This blog article will explain how to import a .bacpac file to Microsoft SQL Server which is created from ...

    Read more
  • [Solved] – Backspace not working in HTML Web Resources

    11 May’ 2018

    Issue: When we use a HTML web resource in Dynamics 365 CRM forms or even as a separate navigation, we sometimes face is...

    Read more
  • Dynamics 365 Tip: Sending Emails using Unified Interface

    10 May’ 2018

    Introduction: The unified client which was released D365 V9 had a very refreshing UI and lots of features. One of the b...

    Read more
  • Filtering Records on BPF unlike on Form – D365

    10 May’ 2018

    Introduction: Working with D365 is best when you’re trying to use as much OOB stuff as possible. Simplest configurati...

    Read more
  • Filter records in gallery control based on value selected in other gallery control in PowerApps.

    10 May’ 2018

    Introduction: This blog explains how to Filter records in gallery control based on value selected in other gallery cont...

    Read more