rwilson504 / PCFControls

Reusable PowerApps Control Framework (PCF) controls.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to load entity data?

ArtKarp opened this issue · comments

commented

I created a canvas app and added the calendar control.

I selected an event entity and set the field for the event name, id, start date/tim, end date/time.

When I run the app, no event records are displayed in the month I am viewing
(there are records that should show up)

For testing, I added a gallery on the same screen and it populates with all the fields I have selected in the calendar control.

I also tried selecting a view and that didn't return any data either.

I read over your set up docs multiple times. However, it seems I have missed something.
What causes the records to be loaded from a CDS entity in a canvas app?

Thanks

So first can you tell me if the Date on your calendar always shows December 1969?
image

It appears I have a loop in my calendar for the calendar date. This appears to happen because input properties for Date or Date/Time default instead being null when nothing is entered. To fix do this on your canvas app.

On the OnStart of the App create a variable for CalendarDate and set it to Today()
image

Next on your Calendar properties in the calendarDate property enter the variable name of CalendarDate
image

Finally in the OnChange event of the control enter the following but replace the raw_RAW.Calendar.Calendar(00000001-0000-0000-0001-00000000009b)1 text with whatever your control name is after it was dropped on the form.
image

You won't see any of this work though until you save the app, close the app in the editor, then re-open the app.

Secondly I'm seeing that the DataSet is always just returning 25 records no matter what in my system even though i can see that if i do a RowCount on my datasource everything is fine. I have to imaging this is an MS bug, i'll go ahead and report it on the forum.
image

For now I would utilize a Collection to make sure the data all get processed from the event data source. To do this create a collection in the OnVisible of the Screen you have the calendar control on.
image

Then update the calendar control to point at the collection instead of the CDS entity.
image

Again after you set this property make sure you close the Canvas app in the editor and re-open it to see the changes. As you can see i have more events in June now than i did previously.
image

Here is what the final properties for my control ended up looking like.
image

Thanks again for putting this thing through it's paces. I'm can't wait until more updates are released by MS on all this and the Canvas abilities match those available in the Model components.

The more i'm thinking about this i really think you have to use a collection no matter what because of the way delegation work. Plus the nice thing about using a collection is that it really easy to filter and shape the data the way you want.

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

I'm going to put all this config into a video here real soon and try to fix the issue with the date.

commented

I have spent quite a few hours today trying to make the calendar work.

First, i tried setting the calendardate to Today() using a var as you suggested. When I do this and run the app in the month view, I am not able to to move to any other month than the current one. If I don't use a var for the date AND I link the calendar to an entity I see the scheduled events I expected.

When I add labels with currentRangeStart and currentRangeEnd they always show 12/31/1969 4 PM for both and never change when I move month to month.

The collections I created off the CDS entity with exactly the same data don't seem to show anything. I think I got them to display once or twice, but I am unable to make it happen again.

Below are test collections. I am just trying to a) make the calendar work and b) figure out the best way to do it. I will have to be able to filter the event data at some point to limit the number of records returned. This won't work if I have to pull all the records in an event entity into PA.

Here is the OnStart code:

//Create local collections from CDS entities
ClearCollect(EventsLocal, Events);
ClearCollect(ColorsLocal, 'Color Palette_1');

//collection created from local collections
ClearCollect(
EventsLocalFlat,
AddColumns(
EventsLocal,
"recordcolorhex",
LookUp(ColorsLocal, 'Color Palette' = 'Color Palette', evx_primarybackgroundcolorhex)
)
);

//collection created from CDS entities directly
ClearCollect(
EventsEntityFlat,
AddColumns(
Events,
"recordcolorhex",
LookUp('Color Palette_1', 'Color Palette' = 'Color Palette', evx_primarybackgroundcolorhex)
)
);

The collections with "color palette" being an added column are to add a HEX code to the event record.

So far using a hex code in the data I haven't been able to change the color of events.

When creating a view in a model app, Dynamics lets you add a calendar control to display the view as a calendar. One of the settings is to use a color that has been set as the "color" HEX property of an OptionSet value. Is there anyway to get at that HEX code using your calendar?

Please let me know if you have any further questions. Also, I am happy to set up a Zoom meeting if it would be of help to you.

Thanks