web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Refresh grid content pcf
Power Apps
Unanswered

Refresh grid content pcf

(0) ShareShare
ReportReport
Posted on by 76

I have designed a custom grid control for one of the requirement with subgrid display. I am creating a new record from the control using xrm. Webapi.createrecord.however, the sub grid content is not getting refreshed after record creation.

Update view method of pcf is not called. I have tried to call grid control. Refresh() and notify outputchanged but of no avail. Appreciate help here. 

I have the same question (0)
  • Ben Thompson Profile Picture
    1,400 on at

    Why do you want to refresh the view (that's an additional API call for zero real benefit)?

     

    Unless plugins are running in the background your PCF component already has all the data you need to add the record into the dataset and refresh the grid control yourself

  • Goutham A Profile Picture
    76 on at

    Thanks Ben.

     

    How do I add records to dataset from js. I see dataset. Records does not have and add property. Can you please help?

     

    On the other hand, how do I refresh view without refreshing the page. I tried context.data.refresh(false) but did not work

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Goutham , 

    I think  @ben-thompson  is right, but I am not aware of a way to add records in the dataset. So that would mean that you need to build another (PCF internal) model for your data, which has to be updated each time updateView is called (if your dataset was changed). I think in the end it depends how often you need to add records, and decide if you need to refresh your dataset or make an internal model on top.

    To refresh the dataset from inside your PCF, you need to call:

    context.parameters.dataset.refresh()

    where "dataset" is the name of your "<data-set" property in the manifest.

    Here is the reference: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/reference/dataset/refresh

    There is no parameter for refresh.

    Hope this helps!

     

    Kind regards,

    Diana

  • Ben Thompson Profile Picture
    1,400 on at

    Diana is right - you can't update the Dataset itself - but you can refresh it (it's an additional api call though, so I would use that approach within a D365 world (10,000+ api calls a day) and not in a power app world (2,000 calls a day).

     

    In the last few dataset PCF's I've created the data ends up in a more flexible JSON object - so we can manipulate it appropriately (say to consolidate figures or perform calculations).

  • Goutham A Profile Picture
    76 on at

    Thank You Ben and Diana!! and yes, I have already tried this context.dataset.referesh() but did not work. I also tried Xrm.page.data.refersh(), calling notifyourputchanged() and having an input variable in pcf, then updating it in success call back of create record(so that update view will be triggered) but none of them refreshed the custom grid dataset.  OOB grids are getting refreshed(Async) when i call Xrm.page.data.refersh().

     

    However, when i refresh entire page, I am able to see the updates in custom grid.(this is not what i want)

  • Diana Birkelbach Profile Picture
    3,072 Most Valuable Professional on at

    Hi @Goutham , 

    Given the tests that you mentioned, I'd like to specify a few things. Maybe we get closer to something that we overlooked.

     

    - How do you create the record? Since you are inside a PCF, you should create it using the feature "webApi" that you declare in the manifest 

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

    After that you get in your "context" a "webAPI".

    Using Xrm.* inside a PCF is not supported.

     

    - calling notityOutputChanges will have no effect for a dataset PCF. That's because there are no output parameters allowed.

     

    - It is not possible to mix a field-PCF with a dataset-PCF. In a dataset PCF you can have also properties, but only of type "input" (not of type "bound"). That means that the control won't be refreshed when the input parameter changes.

     

    So my next test would be:

    Being inside the PCF code, after the creation of the record, wait for the promise, and then call

    context.parameters.<yourDatasetName>.refresh()

    and check the console if you get an error. Check the network protocol, to see the corresponding request and the response. Is the new record listed there? 

    If I've got it wrong, if you've actually meant to call a refresh from outside the PCF (from scripting), we need to work another way. Just let me know.

     

    Kind regards,

    Diana

  • Goutham A Profile Picture
    76 on at

    Thank you for detailed analysis Diane!! yes i did Try dataset.refresh()  inside success callback of webapi.create but the content inside dataset did not update. I even tried to call dataset.refersh() and also xrm.page.data.refersh()(as supported for now but may discontinue in future) inside  window.timeout at regular intervals(Say 5000 ms) after record creation as a test, but did not work too.

     

    No sure if i am missing any concept(which may be minor one). for now, only way i see to refresh the dataset is to refresh the form.

  • jebernar Profile Picture
    Microsoft Employee on at

    Hi Goutham,

     

    Can you provide more details on the repro? I have tried Diana's suggestion and am able to create records, refresh the dataset, and the updateView is called again with the new record. Can you share the code snippet(s) of what you've tried (and whether you observed any differences with the different things you've tried)?

     

    Have you tried looking at the network tab in the browser's F12 tools to check if either the create or refresh network calls are not going out?

  • Verified answer
    Goutham A Profile Picture
    76 on at

    Thank you everyone for your reply!! The issue is with React framework not rerendering and calling dataset.referesh() and  force rendering the reactDOM fixed the issue,

  • Abhinav11 Profile Picture
    10 on at

    Hello @Goutham ,

     

    I'm also facing the same issue.. Can you please share how you resolved this issue.

    Thanks in advance.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard