Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Answered

Help required for referring Entities in Common Data Service in Power Apps Component framework.

(0) ShareShare
ReportReport
Posted on by 64

Hi Team,

 

I need help in connecting Commondata service account entity and perform CRUD operations in PCF control.

Tried to get the api package for npm didn't find any. 

The requirement is to have a  account list poupulated like we have grid in cds and on double click on the list item need to open a popup and edit and save it back to the list and finally update the list in CDS.

 

Could you please guide me on this?

 

Regards,

Sarath Mohan

  • Verified answer
    ScottDurow Profile Picture
    1,039 on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    Also, I added a load of samples on how to use the Model Driven Xrm.WebApi in a branch of the Microsoft PowerApps Samples Repo - https://github.com/scottdurow/PowerApps-Samples/blob/model-driven-app-webapi/cds/webapi/ts-model-driven-app/HowToRunSamples.md

     

    Hope this helps!

  • Verified answer
    Ben Thompson Profile Picture
    1,400 on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    That diagram really doesn't help so let's see if I have this right:

     

    You have a Datagrid control on a subgrid showing child account records.

    You wish to display the list of child accounts on within the Datagrid control

    When you click on a child account record you need a pop-up modal window to appear in which you can edit values and then save the results back to the system.

     

    All that is achievable but it will require a fair amount of JS / TS knowledge but there are some examples that will help

     

    https://docs.microsoft.com/en-us/powerapps/developer/component-framework/sample-controls/data-set-grid-control 

     

    shows how to use a datagrid control - pay attention to the private onRowClick(event: Event) event as you will need that to create the modal form.

     

    https://docs.microsoft.com/en-us/powerapps/developer/component-framework/sample-controls/increment-control shows you how to render a form (note the example uses the name label for the text field which may cause confusion)

     

    I can't find an example for updating a record so here is some very quick code

     

    var id=guid of record;
    var data={"name": nameInputValue};
    
    context.webAPI.updateRecord("account", id, data).then(successCallback, errorCallback);

     

  • v-xida-msft Profile Picture
    on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    Hi @SarathMohan ,

    Have you taken a try with the solution @ben-thompson and I provided above?

     

    Based on the needs that you mentioned, I think the solution provided above could achieve your needs. @ben-thompson  I also agree with your thought above.

     

    Please take a try with above solution, check if it would help in your scenario. If you have some issue with above solution, please let us know here.

     

    Best regards,

  • SarathMohan Profile Picture
    64 on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    Thanks for the response it really helped. Elaborating my use case.

    Thanks for the response , I will explain it in a diagram that would be more appropriate. Basically I am looking for something as attached .

     

    I am able to draw the chart using google charts with hard coded values.

    However, I am looking for 

    1. Populate the data from account entity- Bascially trying with TS for retrieve data etc.

    2. Edit the record while I click on the node and edit the details and submit back.

     

    I may be asking very basic questions as I am starting with PCF control dev activities.

     

    Thank you

    Sarath Mohan

     

     

  • SarathMohan Profile Picture
    64 on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    Thanks for the response , I will explain it in a diagram that would be more appropriate. Basically I am looking for something as attached .

     

    I am able to draw the chart using google charts with hard coded values.

    However, I am looking for 

    1. Populate the data from account entity- Bascially trying with TS for retrieve data etc.

    2. Edit the record while I click on the node and edit the details and submit back.

     

    I may be asking very basic questions as I am starting with PCF control dev activities.

     

    Thank you

    Sarath Mohan

     

     

  • Ben Thompson Profile Picture
    1,400 on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    @v-xida-msft  context.navigation.openForm(options, parameters) opens a new form in place of the current form unless it's a Quick create form and as the requirement is to update the account record the Quick Create form isn't an option.

     

    Xrm.navigation.navigateTo is the function I think you are thinking of which would allow the opening an edit form in a Modal window but that command isn't available in the context API of a PCF Component and I wouldn't recommend it as currently the load routine seems to override the global context of the page causing subsequent issues.

  • v-xida-msft Profile Picture
    on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    Hi @SarathMohan ,

    Could you please share a bit more about your scenario?

    Do you want to open a Pop-Up, and then edit the specific account record based on the passed account id (GUID) value?

     

    Based on the needs that you mentioned, I think the Navigation API exposed under the PowerApps Component Framework could achieve your needs:

    context.navigation.openForm(options, parameters)

    please check the following article for more details:

    https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/navigation/openform

     

    You could use the context.navigation.openForm(options, parameters) function to open a Edit form to edit your specific account record.

     

    In addition, I also agree with @ben-thompson 's thought almost. The WebApi API under the PowerApps Component Framework could also achieve your needs.

    But before using WebApi API in your PCF control, you must declare the WebApi feature you want to use in your ControlManifest.Input.xml file firstly:

    <feature-usage>
     <uses-feature name="WebAPI" required="true" />
     </feature-usage>

    then you could use the following function to update the specific account record:

    context.webAPI.updateRecord(entityLogicalName, id, data).then(successCallback, errorCallback)

    Please check the following article for more details:

    https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/webapi/updaterecord

     

    Best regards, 

  • Ben Thompson Profile Picture
    1,400 on at
    Re: Help required for referring Entities in Common Data Service in Power Apps Component framework.

    There is no api package in npm as the webapi is a flag that you switch on in the ControlManifest.Input.xml file. Enabling 

     

    <feature-usage>
     <uses-feature name="Utility" required="true" />
     <uses-feature name="WebAPI" required="true" />
    </feature-usage>

      

    should be enough and the documentation for retrieving additional fields and updating the record can be found at https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/webapi/retrieverecord

     

    You may also want to use the Utility feature as that will allow you to identify the type of attributes you are displaying https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/utility/getentitymetadata and how to open a lookup dialog see context.utils.lookupObjects(lookupOptions)

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 87 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 71 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 65 Super User 2025 Season 1

Overall leaderboard