{"id":26508,"date":"2021-01-20T11:26:17","date_gmt":"2021-01-20T11:26:17","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=26508"},"modified":"2021-03-06T09:08:51","modified_gmt":"2021-03-06T09:08:51","slug":"what-is-popupservice-in-powerapps-component-framework","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2021\/01\/what-is-popupservice-in-powerapps-component-framework\/","title":{"rendered":"What is PopupService in PowerApps Component Framework?"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p style=\"text-align: justify;\">While creating PCF control, we have mostly encountered difficulties to create popups and dialog boxes. We use external UI libraries like Fluent UI that enables us to manage popups in our PCF control.<\/p>\n<p>Have you heard of PopupService in PowerApps Component Framework?<\/p>\n<p style=\"text-align: justify;\">Let us find out what the PopupService is.<\/p>\n<p style=\"text-align: justify;\">PopupService is a native PCF option that we can use to manage popups in the PCF control.<\/p>\n<p style=\"text-align: justify;\">Sometimes you may design PCF control wherein your control does not require including Fluent UI or any other external library for popups. In this situation, you can go with native PopupService option to create popups.<\/p>\n<p style=\"text-align: justify;\">PopupService includes seven methods to interact with the popups including createPopup, closePopup, deletePopup, openPopup, updatePopup, getPopupsId and setPopupsId. To know more about these methods, follow the link <a href=\"https:\/\/docs.microsoft.com\/en-us\/powerapps\/developer\/component-framework\/reference\/popupservice\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<h2>Prerequisites<\/h2>\n<p>\u2022 Microsoft PowerApps CLI must be installed.<br \/>\n\u2022 Should be familiar in creating basic field control.<\/p>\n<p style=\"text-align: justify;\">Below are the steps to create a PCF control, which includes a button. By clicking this button our custom popup will open.<\/p>\n<p style=\"text-align: justify;\">1. In index.ts file, create three global variables in class which will include a container to append the button in it, PopUpService which will give us the methods discussed in the introduction of this blog and isUpdateViewCalled to restrict extra updateView() call with default value as false.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/1PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26533 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/1PopupService-in-PowerApps-Component-Framework.png\" alt=\"1PopupService in PowerApps Component Framework\" width=\"880\" height=\"226\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/1PopupService-in-PowerApps-Component-Framework.png 880w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/1PopupService-in-PowerApps-Component-Framework-300x77.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/1PopupService-in-PowerApps-Component-Framework-768x197.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/1PopupService-in-PowerApps-Component-Framework-660x170.png 660w\" sizes=\"(max-width: 880px) 100vw, 880px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">2. Initialize the container in init() method of PCF.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/2PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26534 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/2PopupService-in-PowerApps-Component-Framework.png\" alt=\"2PopupService in PowerApps Component Framework\" width=\"883\" height=\"85\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/2PopupService-in-PowerApps-Component-Framework.png 883w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/2PopupService-in-PowerApps-Component-Framework-300x29.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/2PopupService-in-PowerApps-Component-Framework-768x74.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/2PopupService-in-PowerApps-Component-Framework-660x64.png 660w\" sizes=\"(max-width: 883px) 100vw, 883px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">3. In updateView() method we are going to create a button on click of which a popup will appear. At first, we will check the condition of this._isUpdateViewCalled to call the updateView method only once and not multiple times. Further, we will create four variables for our html container, button element, popup content and a close button.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/3PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26535 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/3PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"665\" height=\"119\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/3PopupService-in-PowerApps-Component-Framework.png 665w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/3PopupService-in-PowerApps-Component-Framework-300x54.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/3PopupService-in-PowerApps-Component-Framework-660x118.png 660w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">4. After this variable declaration in updateView() method, create and append button element to the htmlContainer. Let the name of button be \u2018Quick View\u2019, by clicking which it will call popUpClick() that will open the popup. As shown below we also added a class name \u2018button\u2019 to give some style to our button.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/4PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26536 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/4PopupService-in-PowerApps-Component-Framework.png\" alt=\"4PopupService in PowerApps Component Framework\" width=\"500\" height=\"179\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/4PopupService-in-PowerApps-Component-Framework.png 500w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/4PopupService-in-PowerApps-Component-Framework-300x107.png 300w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>Css:<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26537 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"289\" height=\"154\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">To add CSS in your PCF control, create a .css file and add your css in it. To use that file, add it in the resources part in ControlManifest.Input.xml file as shown below:<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework2.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26538 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework2.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"364\" height=\"83\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework2.png 364w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework2-300x68.png 300w\" sizes=\"(max-width: 364px) 100vw, 364px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">5. Now it is time to create the content for the popup. After creating and appending \u2018Quick View\u2019 button to htmlContainer, add logic to create the content, which can be either a HTML or a plain text. For the demo purpose, we will show primary contact record detail of the account on which our control is present. We will retrieve the record using webApi.retrieveMultipleRecords function and in success callback function, we will create the popup content and set true to isUpdateViewCalled for not calling it again.<\/p>\n<p>In content, we will create a HTML table in which we will show three field values &#8211; Name, Email address and Phone number of primary contact. You can choose any field you want along with the table; we will add a button to close the popup on click of which we will call the close Popup method.<\/p>\n<p>So, first we will create fetchXML query and retrieve the record.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26539 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"983\" height=\"411\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5PopupService-in-PowerApps-Component-Framework.png 983w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5PopupService-in-PowerApps-Component-Framework-300x125.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5PopupService-in-PowerApps-Component-Framework-768x321.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5PopupService-in-PowerApps-Component-Framework-660x276.png 660w\" sizes=\"(max-width: 983px) 100vw, 983px\" \/><\/a><\/p>\n<p>Further will create the popup content in the success callback function.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework5.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26540 size-large\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework5-1024x396.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"665\" height=\"257\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework5-1024x396.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework5-300x116.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework5-768x297.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework5-660x255.png 660w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/PopupService-in-PowerApps-Component-Framework5.png 1055w\" sizes=\"(max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">We also added \u201ccontainer\u201d css class to the popUpContent and \u201ccloseButton\u201d class to the button on the popup. In addition, we added some styling to the table and its content.<\/p>\n<p>Css:<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5-PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26541 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5-PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"388\" height=\"659\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5-PopupService-in-PowerApps-Component-Framework.png 388w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/5-PopupService-in-PowerApps-Component-Framework-177x300.png 177w\" sizes=\"(max-width: 388px) 100vw, 388px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">6. Now it is time to create our popup Object. Before creating it we need to make an interface the above class. While creating the interface, extend it to ComponentFramework.FactoryApi.Popup.Popup. Now we can use this interface as a definition type for our popup object.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26542 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"876\" height=\"154\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6PopupService-in-PowerApps-Component-Framework.png 876w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6PopupService-in-PowerApps-Component-Framework-300x53.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6PopupService-in-PowerApps-Component-Framework-768x135.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6PopupService-in-PowerApps-Component-Framework-660x116.png 660w\" sizes=\"(max-width: 876px) 100vw, 876px\" \/><\/a><\/p>\n<p>Will create the Popup Object below our html content, in which we will add popup properties like,<br \/>\ncloseOnOutsideClick: Indicates whether popup will close with an outside mouse click. When set to false, the popup will not close with an outside mouse click.<br \/>\ncontent: Static DOM element to be inserted of type HTMLElement.<br \/>\nname: Unique name of Popup.<br \/>\ntype: The type of popup, which is described in the enum PopupType. Root: 1 and Nested: 2<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6-PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26543 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6-PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"559\" height=\"304\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6-PopupService-in-PowerApps-Component-Framework.png 559w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/6-PopupService-in-PowerApps-Component-Framework-300x163.png 300w\" sizes=\"(max-width: 559px) 100vw, 559px\" \/><\/a><\/p>\n<p>The createPopup(popUpOptions) method will create our popup.<\/p>\n<p style=\"text-align: justify;\">7. After configuring our control on a field in the form, the button will look as shown in the below image:<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26544 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"895\" height=\"281\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7PopupService-in-PowerApps-Component-Framework.png 895w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7PopupService-in-PowerApps-Component-Framework-300x94.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7PopupService-in-PowerApps-Component-Framework-768x241.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7PopupService-in-PowerApps-Component-Framework-660x207.png 660w\" sizes=\"(max-width: 895px) 100vw, 895px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">On click of the above button, we will call our popUpClick() in which we are calling openPopup(popUpName) method, that will open the popup created in the above step.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7-PopupService-in-PowerApps-Component-Framework.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-26545\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7-PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"441\" height=\"87\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7-PopupService-in-PowerApps-Component-Framework.png 441w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/7-PopupService-in-PowerApps-Component-Framework-300x59.png 300w\" sizes=\"(max-width: 441px) 100vw, 441px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Now you can see the popup as shown in the below image with details of Primary contact in it.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/07PopupService-in-PowerApps-Component-Framework.png\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26546 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/07PopupService-in-PowerApps-Component-Framework.png\" alt=\"PopupService in PowerApps Component Framework\" width=\"461\" height=\"252\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/07PopupService-in-PowerApps-Component-Framework.png 461w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/07PopupService-in-PowerApps-Component-Framework-300x164.png 300w\" sizes=\"(max-width: 461px) 100vw, 461px\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">We can see the three fields with their values and a close button. On click of \u2018Close\u2019 button, we will call closeCustomPopUp() in which we will call closePopup(popUpName) to close our custom popup.<\/p>\n<p style=\"text-align: justify;\">Below is the complete code for the above Popup.<\/p>\n<p>CSS:<br \/>\n.container {<br \/>\nwidth: 400px;<br \/>\nheight: 200px;<br \/>\nbackground-color: azure;<br \/>\nposition: absolute;<br \/>\ntop: 50%;<br \/>\nleft: 50%;<br \/>\ntransform: translate(-50%, -50%);<br \/>\nborder: 1px solid slategray;<br \/>\npadding: 10px;<br \/>\nborder-radius: 10px;<br \/>\n}<\/p>\n<p>.button {<br \/>\nborder: 1px solid #333;<br \/>\nborder-radius: 5px;<br \/>\nbackground-color: #EFEFEF;<br \/>\nwidth: 100%;<br \/>\npadding: 10px;<br \/>\n}<\/p>\n<p>.closeButton {<br \/>\nwidth: 100%;<br \/>\nborder: 1px solid black;<br \/>\nmargin-top: 10px;<br \/>\nbackground: azure;<br \/>\npadding: 10px;<br \/>\n}<\/p>\n<p>table {<br \/>\nwidth: 100%;<br \/>\nbackground: #EFEFEF;<br \/>\nborder: 1px solid #333333;<br \/>\ncolor: black;<br \/>\n}<\/p>\n<p>td {<br \/>\npadding: 10px;<br \/>\n}<\/p>\n<p>Code:<br \/>\nIndex.ts (TypeScript)<br \/>\nimport { IInputs, IOutputs } from &#8220;.\/generated\/ManifestTypes&#8221;;<br \/>\ninterface PopUpInterface extends ComponentFramework.FactoryApi.Popup.Popup {<br \/>\npopupProp: object;<br \/>\n}<br \/>\nexport class CustomPopUp implements ComponentFramework.StandardControl&lt;IInputs, IOutputs&gt; {<br \/>\nprivate _container: HTMLDivElement;<br \/>\nprivate _popUpService: ComponentFramework.FactoryApi.Popup.PopupService;<br \/>\nprivate _isUpdateViewCalled: boolean = false;<br \/>\n\/**<br \/>\n* Empty constructor.<br \/>\n*\/<br \/>\nconstructor() { }<\/p>\n<p>\/**<br \/>\n* Used to initialize the control instance. Controls can kick off remote server calls and other initialization actions here.<br \/>\n* Data-set values are not initialized here, use updateView.<br \/>\n* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to property names defined in the manifest, as well as utility functions.<br \/>\n* @param notifyOutputChanged A callback method to alert the framework that the control has new outputs ready to be retrieved asynchronously.<br \/>\n* @param state A piece of data that persists in one session for a single user. Can be set at any point in a controls life cycle by calling &#8216;setControlState&#8217; in the Mode interface.<br \/>\n* @param container If a control is marked control-type=&#8217;standard&#8217;, it will receive an empty div element within which it can render its content.<br \/>\n*\/<br \/>\npublic init(context: ComponentFramework.Context&lt;IInputs&gt;, notifyOutputChanged: () =&gt; void, state: ComponentFramework.Dictionary, container: HTMLDivElement) {<br \/>\nthis._container = container;<br \/>\n}<br \/>\npublic popUpClick = () =&gt; {<br \/>\nthis._popUpService.openPopup(&#8220;CustomPopUp&#8221;);<br \/>\n}<\/p>\n<p>public closeCustomPopUp = () =&gt; {<br \/>\nthis._popUpService.closePopup(&#8220;CustomPopUp&#8221;);<br \/>\n}<br \/>\n\/**<br \/>\n* Called when any value in the property bag has changed. This includes field values, data-sets, global values such as container height and width, offline status, control metadata values such as label, visible, etc.<br \/>\n* @param context The entire property bag available to control via Context Object; It contains values as set up by the customizer mapped to names defined in the manifest, as well as utility functions<br \/>\n*\/<br \/>\npublic updateView(context: ComponentFramework.Context&lt;IInputs&gt;): void {<br \/>\nif (!this._isUpdateViewCalled) {<br \/>\nlet htmlContainer: HTMLDivElement;<br \/>\nlet quickViewButton: HTMLButtonElement;<br \/>\nlet popUpContent: HTMLDivElement;<br \/>\nlet closeButton: HTMLButtonElement;<\/p>\n<p>\/\/============ content of our popup =============<br \/>\nhtmlContainer = document.createElement(&#8216;div&#8217;);<br \/>\n\/\/button to show our popup<br \/>\nquickViewButton = document.createElement(&#8216;button&#8217;);<br \/>\nquickViewButton.innerHTML = &#8220;Quick View&#8221;;<br \/>\nquickViewButton.classList.add(&#8216;button&#8217;);<br \/>\nquickViewButton.onclick = () =&gt; this.popUpClick();<br \/>\nhtmlContainer.appendChild(quickViewButton);<br \/>\n\/\/@ts-ignore<br \/>\nlet page = context.page;<br \/>\nlet entityId = page.entityId;<br \/>\nlet fetchXml = &#8220;&lt;fetch version=&#8217;1.0&#8242; output-format=&#8217;xml-platform&#8217; mapping=&#8217;logical&#8217; distinct=&#8217;false&#8217;&gt;&#8221; +<br \/>\n&#8220;&lt;entity name=&#8217;account&#8217;&gt;&#8221; +<br \/>\n&#8220;&lt;attribute name=&#8217;name&#8217; \/&gt;&#8221; +<br \/>\n&#8220;&lt;attribute name=&#8217;primarycontactid&#8217; \/&gt;&#8221; +<br \/>\n&#8220;&lt;attribute name=&#8217;telephone1&#8242; \/&gt;&#8221; +<br \/>\n&#8220;&lt;attribute name=&#8217;accountid&#8217; \/&gt;&#8221; +<br \/>\n&#8220;&lt;order attribute=&#8217;name&#8217; descending=&#8217;false&#8217; \/&gt;&#8221; +<br \/>\n&#8220;&lt;filter type=&#8217;and&#8217;&gt;&#8221; +<br \/>\n&#8220;&lt;condition attribute=&#8217;accountid&#8217; operator=&#8217;eq&#8217; value='{&#8221; + entityId + &#8220;}&#8217; \/&gt;&#8221; +<br \/>\n&#8220;&lt;\/filter&gt;&#8221; +<br \/>\n&#8220;&lt;link-entity name=&#8217;contact&#8217; from=&#8217;contactid&#8217; to=&#8217;primarycontactid&#8217; visible=&#8217;false&#8217; link-type=&#8217;outer&#8217;&gt;&#8221; +<br \/>\n&#8220;&lt;attribute name=&#8217;emailaddress1&#8242; \/&gt;&#8221; +<br \/>\n&#8220;&lt;attribute name=&#8217;telephone1&#8242; \/&gt;&#8221; +<br \/>\n&#8220;&lt;\/link-entity&gt;&#8221; +<br \/>\n&#8220;&lt;\/entity&gt;&#8221; +<br \/>\n&#8220;&lt;\/fetch&gt;&#8221;;<br \/>\nlet fetchQuery = &#8220;?fetchXml=&#8221; + encodeURIComponent(fetchXml);<br \/>\ncontext.webAPI.retrieveMultipleRecords(page.entityTypeName, fetchQuery).then((record: any) =&gt; {<br \/>\n\/\/take the value in record variable<br \/>\nrecord = record.entities[0];<br \/>\nthis._isUpdateViewCalled = true;<br \/>\npopUpContent = document.createElement(&#8216;div&#8217;);<br \/>\npopUpContent.innerHTML = &#8220;&lt;table&gt;&#8221; +<br \/>\n&#8220;&lt;tr&gt;&#8221; +<br \/>\n&#8220;&lt;td&gt;Primary Contact: &#8221; + record[&#8220;_primarycontactid_value@OData.Community.Display.V1.FormattedValue&#8221;] + &#8221; &lt;\/td&gt;&#8221; +<br \/>\n&#8220;&lt;\/tr&gt;&#8221; +<br \/>\n&#8220;&lt;tr&gt;&#8221; +<br \/>\n&#8220;&lt;td&gt;Email: &#8221; + record[&#8220;contact1.emailaddress1&#8243;] + &#8221; &lt;\/td&gt;&#8221; +<br \/>\n&#8220;&lt;\/tr&gt;&#8221; +<br \/>\n&#8220;&lt;tr&gt;&#8221; +<br \/>\n&#8220;&lt;td&gt;Telephone: &#8221; + record[&#8220;contact1.telephone1&#8243;] + &#8221; &lt;\/td&gt;&#8221; +<br \/>\n&#8220;&lt;\/tr&gt;&#8221; +<br \/>\n&#8220;&lt;\/table&gt;&#8221;;<br \/>\npopUpContent.classList.add(&#8220;container&#8221;);<br \/>\ncloseButton = document.createElement(&#8216;button&#8217;);<br \/>\ncloseButton.innerHTML = &#8220;Close&#8221;;<br \/>\ncloseButton.classList.add(&#8216;closeButton&#8217;);<br \/>\ncloseButton.onclick = () =&gt; this.closeCustomPopUp();<br \/>\npopUpContent.appendChild(closeButton);<\/p>\n<p>\/\/ Popup object<br \/>\nlet popUpOptions: PopUpInterface = {<br \/>\ncloseOnOutsideClick: false,<br \/>\ncontent: popUpContent,<br \/>\nname: &#8216;CustomPopUp&#8217;, \/\/ unique popup name<br \/>\ntype: 1, \/\/ Root popup<br \/>\npopupProp: {}<br \/>\n};<br \/>\nthis._popUpService = context.factory.getPopupService();<br \/>\nthis._popUpService.createPopup(popUpOptions);<\/p>\n<p>});<br \/>\nthis._container.appendChild(htmlContainer);<br \/>\n}<br \/>\n}<\/p>\n<p>\/**<br \/>\n* It is called by the framework prior to a control receiving new data.<br \/>\n* @returns an object based on nomenclature defined in manifest, expecting object[s] for property marked as \u201cbound\u201d or \u201coutput\u201d<br \/>\n*\/<br \/>\npublic getOutputs(): IOutputs {<br \/>\nreturn {};<br \/>\n}<\/p>\n<p>\/**<br \/>\n* Called when the control is to be removed from the DOM tree. Controls should use this call for cleanup.<br \/>\n* i.e. cancelling any pending remote calls, removing listeners, etc.<br \/>\n*\/<br \/>\npublic destroy(): void {<br \/>\n\/\/ Add code to cleanup control if necessary<br \/>\n}<br \/>\n}<\/p>\n<h2>Conclusion<\/h2>\n<p style=\"text-align: justify;\">As illustrated above, you can now add popups in PCF control using PopupService.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/productivity-apps\/attach-2-dynamics-365-crm-upload-multiple-files-sharepoint-cloud-storage\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-26531 size-full\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/a2d.jpg\" alt=\"\" width=\"800\" height=\"200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/a2d.jpg 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/a2d-300x75.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/a2d-768x192.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2021\/01\/a2d-660x165.jpg 660w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction While creating PCF control, we have mostly encountered difficulties to create popups and dialog boxes. We use external UI libraries like Fluent UI that enables us to manage popups in our PCF control. Have you heard of PopupService in PowerApps Component Framework? Let us find out what the PopupService is. PopupService is a native\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2021\/01\/what-is-popupservice-in-powerapps-component-framework\/\">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":[16,19,44,1929,1985],"tags":[545,592,2129,2130],"class_list":["post-26508","post","type-post","status-publish","format-standard","hentry","category-dynamics-365","category-dynamics-crm","category-power-apps","category-pcf","category-power-automate","tag-dynamics-365-crm","tag-dynamics-crm","tag-popupservice-in-powerapps","tag-powerapps-component-framework"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/26508","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=26508"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/26508\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=26508"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=26508"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=26508"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}