cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KurtH1994
Helper I
Helper I

Editable Grid on Powerapps creating duplicates when patching a collection

Hi,

 

New to powerapps and not entirely sure what is happening with my app. I am patching data from a collection and for some reason when i click my "SAVE WIP" button it is creating a duplicate of my first row in the gallery from the colgriddata. Below is a copy of the code for the onselect function for my "SAVE WIP" button. Every time i click the button it keeps returning duplicates even though no data was edited.

 

recording.gif

 If(
varGridEdit,
If(
!IsBlank(
LookUp(
colGridData,
IsBlank(Title)
)
),
Notify(
"Please Enter Block Number",
NotificationType.Error,
2000
),
Patch(
'QSV WIP Monitor',
UpdateIf(
colGridData,
Created = Blank(),
{ID : Blank()}
)
);
Remove('QSV WIP Monitor',colDelete);
Notify(
"WIP Updated",
NotificationType.Success,
2000
);
Clear(colDelete);
Select(btnLoadData);
Set(
varGridEdit,
!varGridEdit
)
),
Set(
varGridEdit,
!varGridEdit
)
);

 

Thanks,

Kurt

1 ACCEPTED SOLUTION

Accepted Solutions

At the end of the Save command. Previously we had Clear(colGridData). It stores the duplicate. That's good.

Now will replace that line with this

ClearCollect(colGridData, DataSource); //Clears the collection and stores data from Data source

 So that it clears the collection and gets the updated data from Datasource together. So that your gallery items property will use the collection.

 

View solution in original post

12 REPLIES 12
StalinPonnusamy
Super User
Super User

Hi @KurtH1994 

 

Not seeing the code to Clear the collection once data is Saved. Please try this code

 

 

If(varGridEdit,
If(
!IsBlank(LookUp(colGridData,IsBlank(Title))),
Notify("Please Enter Block Number",NotificationType.Error,2000),
Patch('QSV WIP Monitor', UpdateIf(colGridData, IsBlank(Created),{ID : Blank()})
);

Remove('QSV WIP Monitor',colDelete);
Notify("WIP Updated",NotificationType.Success,2000);

Clear(colDelete);
Select(btnLoadData);
);

Set(varGridEdit,!varGridEdit);
Clear(colGridData);

 

 

Thanks,
Stalin - Learn To Illuminate

 

Hi @StalinPonnusamy 

 

That works for not populating duplicates, however i want to retain the values when editing the gallery table. As the gallery items uses "colGridData" i can no longer see the previous entries to edit. See below:

 

recording.gif

 

Thank you for assisting me!

 

Kurt

StalinPonnusamy
Super User
Super User

Hi @KurtH1994 

 

I have updated the above code. Please try and let me know.


Thanks,
Stalin - Learn To Illuminate

Hi @KurtH1994 

 

We need to load the data from Datasource to collection again to start to make edits.

Set(varGridEdit,!varGridEdit);
ClearCollect(colGridData, DataSource); //Clears the collection and stores data from Data source

 

Hi @StalinPonnusamy 

 

Apologies for my lack of understanding, do i need to put this at the start of the complete code you posted previously?

 

Thanks 

At the end of the Save command. Previously we had Clear(colGridData). It stores the duplicate. That's good.

Now will replace that line with this

ClearCollect(colGridData, DataSource); //Clears the collection and stores data from Data source

 So that it clears the collection and gets the updated data from Datasource together. So that your gallery items property will use the collection.

 

KurtH1994
Helper I
Helper I

Hi @StalinPonnusamy 

 

Thanks a lot! That worked with a couple of tweeks with bracketing and semi colons!

 

Below complete code:

If(varGridEdit,
If(
!IsBlank(LookUp(colGridData,IsBlank(Title))),
Notify("Please Enter Block Number",NotificationType.Error,2000),
Patch('QSV WIP Monitor', UpdateIf(colGridData, IsBlank(Created),{ID : Blank()})
);
Remove('QSV WIP Monitor',colDelete);
Notify("WIP Updated",NotificationType.Success,2000);
Clear(colDelete);
Select(btnLoadData);
Set(varGridEdit,!varGridEdit)),
Set(
varGridEdit,
!varGridEdit
)
);
ClearCollect(colGridData, 'QSV WIP Monitor'); //Clears the collection and stores data from Data source

 

Really appreciate your help!!

 

Kurt

Hello @StalinPonnusamy 

 

Apologies, but after clicking the save button on my app it appears to be still duplicating the first row of the gallery but not any other rows. Are there any other parts of my app you wish to see in order to understand my problem further?

 

Thanks again for your continued help.

 

Kurt

Could you make it work eventually? 

Val

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,756)