{"id":28783,"date":"2021-07-28T10:34:59","date_gmt":"2021-07-28T10:34:59","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=28783"},"modified":"2026-02-10T12:21:44","modified_gmt":"2026-02-10T06:51:44","slug":"how-to-create-simple-lookup-using-pcf-control","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2021\/07\/how-to-create-simple-lookup-using-pcf-control\/","title":{"rendered":"How to create simple Lookup using PCF Control"},"content":{"rendered":"<h2>Introduction:<\/h2>\n<p>With recent updates to the PowerApps Component Framework (PCF), developers can now create custom PCF controls for lookup fields a capability that was not supported earlier.<\/p>\n<p>Previously, lookup fields in Dataverse and model-driven apps could not be directly bound to PCF controls in a supported manner. However, Microsoft introduced the Lookup.Simple property type, which makes it possible to build fully supported custom lookup experiences using PCF.<\/p>\n<p>In this blog, we\u2019ll walk through how to create a simple lookup PCF control and bind it to a lookup field, using the Primary Contact lookup field on the Account entity as an example.<\/p>\n<p>Scenario Overview<\/p>\n<ul>\n<li>Create a PCF control for a lookup field<\/li>\n<li>Bind it using the Simple property<\/li>\n<li>Allow users to select records using the lookupObjects API<\/li>\n<li>Display and update the selected lookup value correctly in Dataverse<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/07\/image001-ink-3.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-28785 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/07\/image001-ink-3.png\" alt=\"How to create simple Lookup using PCF Control\" width=\"1131\" height=\"349\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/07\/image001-ink-3.png 1131w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/07\/image001-ink-3-300x93.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/07\/image001-ink-3-768x237.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/07\/image001-ink-3-1024x316.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/07\/image001-ink-3-660x204.png 660w\" sizes=\"(max-width: 1131px) 100vw, 1131px\" \/><\/a><\/p>\n<h3><strong>Steps to Create a Lookup PCF Control<\/strong><\/h3>\n<p><strong>Step 1: Add Lookup Property in ControlManifest.Input.xml<\/strong><\/p>\n<p>First, we need to add lookup type property in ControlManifest.Input.xml file using the code given below:<\/p>\n<pre class=\"lang:css gutter:true start:1\">&lt;property\u00a0name=\"sampleProperty\"\u00a0display-name-key=\"Property_Display_Key\"\u00a0description-key=\"Property_Desc_Key\"\u00a0of-type=\"Lookup.Simple\"\u00a0usage=\"bound\"\u00a0required=\"true\"\u00a0\/&gt;\r\n<\/pre>\n<p>This step is critical, as it enables the PCF control to bind directly to a Dataverse lookup field.<\/p>\n<p><strong>Step 2: Define IInputs and IOutputs in the d.ts File<\/strong><\/p>\n<p>Next, define the input and output interfaces so they match the lookup property defined in the manifest.<\/p>\n<pre class=\"lang:css gutter:true start:1\">\/\/\u00a0Define\u00a0IInputs\u00a0and\u00a0IOutputs\u00a0Type.\u00a0They\u00a0should\u00a0match\u00a0with\u00a0ControlManifest.\r\nexport\u00a0interface\u00a0IInputs\u00a0{\r\nsampleProperty:\u00a0ComponentFramework.PropertyTypes.LookupProperty;\r\n}\r\nexport\u00a0interface\u00a0IOutputs\u00a0{\r\nsampleProperty?:\u00a0ComponentFramework.LookupValue[];\r\n}\r\n<\/pre>\n<p>This allows the framework to pass lookup values into the control and receive updated values back.<\/p>\n<p><strong>Step 3: Open Lookup Dialog Using lookupObjects API<\/strong><\/p>\n<p>Now, add the action that, on click of \u2018Find Lookup\u2019 button, it opens the lookupObjects to select the value:<\/p>\n<pre class=\"lang:css gutter:true start:1\">private\u00a0performLookupObjects(entityType:\u00a0string,\u00a0viewId:\u00a0string,\u00a0setSelected:\u00a0(value:\u00a0ComponentFramework.LookupValue,\u00a0update?:\u00a0boolean)\u00a0=&gt;\u00a0void):\u00a0void\u00a0{\r\n\/\/\u00a0Used\u00a0cached\u00a0values\u00a0from\u00a0lookup\u00a0parameter\u00a0to\u00a0set\u00a0options\u00a0for\u00a0lookupObjects\u00a0API\r\nconst\u00a0lookupOptions\u00a0=\u00a0{\r\ndefaultEntityType:\u00a0entityType,\r\ndefaultViewId:\u00a0viewId,\r\nallowMultiSelect:\u00a0false,\r\nentityTypes:\u00a0[entityType],\r\nviewIds:\u00a0[viewId]\r\n};\r\nthis._context.utils.lookupObjects(lookupOptions).then((success)\u00a0=&gt;\u00a0{\r\nif\u00a0(success\u00a0&amp;&amp;\u00a0success.length\u00a0&gt;\u00a00)\u00a0{\r\n\/\/\u00a0Cache\u00a0the\u00a0necessary\u00a0information\u00a0for\u00a0the\u00a0newly\u00a0selected\u00a0entity\u00a0lookup\r\nconst\u00a0selectedReference\u00a0=\u00a0success[0];\r\nconst\u00a0selectedLookupValue:\u00a0ComponentFramework.LookupValue\u00a0=\u00a0{\r\nid:\u00a0selectedReference.id,\r\nname:\u00a0selectedReference.name,\r\nentityType:\u00a0selectedReference.entityType\r\n};\r\n\/\/\u00a0Update\u00a0the\u00a0primary\u00a0or\u00a0secondary\u00a0lookup\u00a0property\r\nsetSelected(selectedLookupValue);\r\n\/\/\u00a0Trigger\u00a0a\u00a0control\u00a0update\r\nthis._notifyOutputChanged();\r\n}\u00a0else\u00a0{\r\nsetSelected({}\u00a0as\u00a0ComponentFramework.LookupValue);\r\n}\r\n},\u00a0(error)\u00a0=&gt;\u00a0{\r\nconsole.log(error);\r\n});\r\n}\r\n<\/pre>\n<p>This opens the standard Dataverse lookup dialog and allows users to select a record.<\/p>\n<p><strong>Step 4: Set Existing Lookup Value Using updateView<\/strong><\/p>\n<p>When the PCF control loads, use the updateView function to populate the control with the existing lookup value.<\/p>\n<pre class=\"lang:css gutter:true start:1\">public\u00a0updateView(context:\u00a0ComponentFramework.Context&lt;IInputs&gt;):\u00a0void\r\n{\r\n\/\/\u00a0Add\u00a0code\u00a0to\u00a0update\u00a0control\u00a0view\r\n\/\/Update\u00a0the\u00a0main\u00a0text\u00a0field\u00a0of\u00a0the\u00a0control\u00a0to\u00a0contain\u00a0the\u00a0raw\u00a0data\u00a0of\u00a0the\u00a0entity\u00a0selected\u00a0via\u00a0lookup\r\nconst\u00a0lookupValue:\u00a0ComponentFramework.LookupValue\u00a0=\u00a0context.parameters.sampleProperty.raw[0];\r\nthis._context\u00a0=\u00a0context;\r\nlet\u00a0propertyValue:any\u00a0=\u00a0lookupValue.name;\r\nthis._input.value\u00a0=\u00a0propertyValue;\r\n}\r\n<\/pre>\n<p>This ensures the lookup field displays the currently selected record when the form loads.<\/p>\n<p><strong>Step 5: Return Updated Lookup Value Using getOutputs<\/strong><\/p>\n<p>Finally, return the updated lookup value to Dataverse using the getOutputs function.<\/p>\n<pre class=\"lang:css gutter:true start:1\">public\u00a0getOutputs():\u00a0IOutputs\r\n{\r\n\/\/\u00a0Send\u00a0the\u00a0updated\u00a0selected\u00a0lookup\u00a0item\u00a0back\u00a0to\u00a0the\u00a0ComponentFramework,\u00a0based\u00a0on\u00a0the\u00a0currently\u00a0selected\u00a0item\r\nreturn\u00a0{\u00a0sampleProperty:\u00a0[this._selectedItem]\u00a0}\u00a0;\r\n}\r\n<\/pre>\n<p>This step ensures that the selected lookup value is saved correctly to the bound field.<\/p>\n<p><strong>\u00a0<\/strong><\/p>\n<p><strong>Conclusion:<\/strong><\/p>\n<p>With the introduction of the Lookup.Simple property type, creating lookup-based PCF controls in Power Apps has become fully supported and much easier.<\/p>\n<p>This approach allows developers to build custom lookup experiences while maintaining compatibility with Dataverse and model-driven apps. When implemented correctly, lookup PCF controls can enhance usability without compromising platform stability.<\/p>\n<p><strong>FAQs <\/strong><\/p>\n<p><strong>What is Lookup.Simple in PCF?<\/strong><\/p>\n<p>Lookup.Simple is a property type introduced in PCF that allows controls to bind directly to Dataverse lookup fields in a supported way.<\/p>\n<p><strong>Can this PCF control be used in model-driven apps?<\/strong><\/p>\n<p>Yes. Lookup PCF controls using Lookup.Simple are fully supported in model-driven apps.<\/p>\n<p><strong>Is multi-select lookup supported with this approach?<\/strong><\/p>\n<p>No. The Lookup.Simple property supports single-value lookups only.<\/p>\n<p><strong>Which API is used to open the lookup dialog?<\/strong><\/p>\n<p>The context.utils.lookupObjects API is used to open the standard Dataverse lookup dialog.<\/p>\n<p><strong>Is this approach supported by Microsoft?<\/strong><\/p>\n<p>Yes. Using Lookup.Simple is the official and supported method for implementing lookup PCF controls.<\/p>\n<p><script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [{\n    \"@type\": \"Question\",\n    \"name\": \"What is Lookup.Simple in PCF?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Lookup.Simple is a property type introduced in PCF that allows controls to bind directly to Dataverse lookup fields in a supported way.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Can this PCF control be used in model-driven apps?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Yes. Lookup PCF controls using Lookup.Simple are fully supported in model-driven apps.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Is multi-select lookup supported with this approach?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"No. The Lookup.Simple property supports single-value lookups only.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Which API is used to open the lookup dialog?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"The context.utils.lookupObjects API is used to open the standard Dataverse lookup dialog.\"\n    }\n  },{\n    \"@type\": \"Question\",\n    \"name\": \"Is this approach supported by Microsoft?\",\n    \"acceptedAnswer\": {\n      \"@type\": \"Answer\",\n      \"text\": \"Yes. Using Lookup.Simple is the official and supported method for implementing lookup PCF controls.\"\n    }\n  }]\n}\n<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: With recent updates to the PowerApps Component Framework (PCF), developers can now create custom PCF controls for lookup fields a capability that was not supported earlier. Previously, lookup fields in Dataverse and model-driven apps could not be directly bound to PCF controls in a supported manner. However, Microsoft introduced the Lookup.Simple property type, which\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2021\/07\/how-to-create-simple-lookup-using-pcf-control\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[44,1929,2053,1985],"tags":[1941],"class_list":["post-28783","post","type-post","status-publish","format-standard","hentry","category-power-apps","category-pcf","category-power-apps-portals","category-power-automate","tag-pcf-control"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/28783","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=28783"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/28783\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=28783"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=28783"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=28783"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}