Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
Unanswered

PCF - issue on multiple subgrids on same form, context parameters are getting confused

Posted on by 5

Subgrids are for different entities, both of which are related to the parent entity.  The form has one field and 2 subgrids. The PCF is  renders checkboxes for available options and is configured on a subgrid for either a many-to-many-relationship or an entity with 2 lookups (the parent and the available options entity). When one PCF entity is on the form, there are no problems. With 2, things get interesting. First off the Power Apps Form designer is allowing me to add and configure the PCF. That is a nice feature. However, when I moved the 2nd subgrid to a new tab, suddenly there were 2 PCF instances shown on the 2nd tab configuration of the Subgrid. I raise this issue, because the first issue I ran into is that the init method is fired multiple times on each tab. I have set breakpoints and have console messages to observe, and the first tab, shows only the config settings on the 1st tab. The 2nd tab is showing config settings from both 1st and 2nd tab. I used the Classic UI to clean up the 2nd tab multi-instances. This was mainly to calm my own fears that this was causing the multi-firing issue.

I am using React and FluentUi for the TSX and passing the event handler from the "index.ts" to the TSX. So, when checkboxes are clicked, it invokes "toggleOption":

	private toggleOption(id: string): void {
...
			if (checkedDatumIndex === -1) {
				data.push({ id: optionDatum.key, name: optionDatum.title });
				console.log(`toggleOption - adding to data (current state isChecked: ${optionDatum.isChecked}), id: ${optionDatum.key}, name: '${optionDatum.title}'`);
				console.log(`toggleOption associate - parentSetName: ${this.parentSetName}, entityId: ${this.entityId}, relationshipName: ${this.relationshipName}, childSetName: ${this.childSetName}`);
				this.webApi?.associateRecord(
					this.parentSetName,
					this.entityId,
					this.relationshipName,
					this.childSetName,
					optionDatum.key);
			}
...

So, the fun and annoying part is that "this.relationshipName" on the 2nd Subgrid (2nd tab) is carrying the configuration info from the first Subgrid (1st tab). The multiple intit firings may have something to do with this. But I am at wit's end. Any help will bwe appreciated.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans