› Dynamics 365, Enterprise › How to Connect with Dynamics 365 and use Lookup Field of Dynamics CRM in PowerApps.

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

 Vaishali Vyas   Leave a comment

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()


Liked it? Share it.

Leave a Reply

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

Time limit is exhausted. Please reload the CAPTCHA.