cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akbarmahfuzalam
Post Prodigy
Post Prodigy

Remove a row from the view of a gallery only If it doesn't have Input from the User.

Greeting for the Day!

 

I am working on an app where the end-user can send their Comments in the text input box. Currently, I have Collection listed in a gallery and Patching all the entry which have a comment on the AHTReason input box. But I want to remove the row which has some entry inside the AHTReason input box after Patching it to Sharepoint List.

 

The formula which I used as of now is working fine but it is not removing the rows from the Gallery it only reset the AHTReason input box to blank.

 

Clear(AHTBULKGallery1);
Collect(
AHTBULKGallery1,
{
Shiftdate: AHTSHIFTDATE.Text,
Enterprise_ID: AHTEID.Text,
LOB: AHTLOB.Text,
Queue: AHTQueue.Text,
Reason: AHTReason.Text,
'Requested By': AHTTLs.Text,
'Uploaded By': AHTUploadeBy.Text
}
);

Notify("Submitting your records...",NotificationType.Information);
ForAll(
AHTBULKGallery1,
If(
!IsBlank(AHTReason.Text),
Patch(
AHTException,
Defaults(AHTException),

{
Shiftdate:AHTSHIFTDATE.Text,
Enterprise_ID:AHTEID.Text,
LOB:AHTLOB.Text,
Queue:AHTQueue.Text,
Reason:AHTReason.Text,
'Requested By':AHTTLs.Text,
'Uploaded By':AHTUploadeBy.Text
}
)
)
);

RemoveIf(AHTBULKGallery1,
!IsBlank(AHTReason.Text)
);
Notify("All records has been submitted successfully!",NotificationType.Success);
Set(gvReset,true);
Set(gvReset,false)

 

 

 

akbarmahfuzalam_0-1598715647716.png

 

9 REPLIES 9
Pstork1
Dual Super User III
Dual Super User III

What is the Items property of the Gallery set to?

 

The problem is that your ForAll statement references the AHTBULKGallery1 which will only ever have one record in it since you do a CLEAR(AHTBULKGallery1) just before you add one record using the Collect(AHTBULKGallery1... So the ForAll only operates on that one record.  The RemoveIF will also only work on that one record.  Your gallery must be getting its records from somewhere else, but you aren't changing those.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 ,

 

Thanks for the input.

 

 the Items property of the Gallery set to some other SP List from where I am getting all the Data in the Gallery.

 

SortByColumns( Filter(WHOSWHO,TeamLead=ddTL_24.Selected.Result),"EnterpriseID",If(SortDescending1,Descending,Ascending))

 

 

Your gallery must be getting its records from somewhere else, but you aren't changing those.

How do I change those? Please advice. Do you want me to remove the Collect and directly take the data from the SP List and then question arrive how do I remove the Rows which have (AHTReason.Text)?

 

Is there any workaround to get this sorted out.

 

The AHTBULKGallery is the Gallery where I am getting all the List of the People. and then I am patching it to other SP List. 

Ask- is it possible to remove the rows where AHTReason that is a text input is having some text inside it.

If you are patching back to the original list then you don't need to remove the rows.  Just add an additional condition to the Filter statement on the gallery that also filters out the records that have been patched.  Something like this

 

SortByColumns( Filter(WHOSWHO,TeamLead=ddTL_24.Selected.Result && !IsBlank(AHTReason)),"EnterpriseID",If(SortDescending1,Descending,Ascending))

Then after you patch the list just refresh the main gallery and it will filter out the records that have been patched.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 

Thank you so much for this suggestion.

 

I did that .." 

SortByColumns( Filter(WHOSWHO,TeamLead=ddTL_24.Selected.Result && !IsBlank(AHTReason)),"EnterpriseID",If(SortDescending1,Descending,Ascending))

Getting error in the Gallery because AHTReason is not there in WHOSWHO SP List I had added in the Gallery Similarly, Few of them are populating as per the Dropdown List. 

akbarmahfuzalam_0-1598723578155.png

 

 

But what changes do I need to make on the below Code

 

Collect(
AHTBULKGallery1,
{
Shiftdate: AHTSHIFTDATE.Text,
Enterprise_ID: AHTEID.Text,
LOB: AHTLOB.Text,
Queue: AHTQueue.Text,
Reason: AHTReason.Text,
'Requested By': AHTTLs.Text,
'Uploaded By': AHTUploadeBy.Text
}
);

Notify("Submitting your records...",NotificationType.Information);
ForAll(
AHTBULKGallery.AllItems,
If(
!IsBlank(AHTReason.Text),
Patch(
AHTException,
Defaults(AHTException),

{
Shiftdate:AHTSHIFTDATE.Text,
Enterprise_ID:AHTEID.Text,
LOB:AHTLOB.Text,
Queue:AHTQueue.Text,
Reason:AHTReason.Text,
'Requested By':AHTTLs.Text,
'Uploaded By':AHTUploadeBy.Text
}
)
)
);

//RemoveIf(AHTBULKGallery1,
//!IsBlank(AHTReason.Text)
//);
Notify("All records has been submitted successfully!",NotificationType.Success);
Set(gvReset,true);
Set(gvReset,false)

In the main list it looks like the column is just called 'Reason' not ATHReason.  So you should change that in the filter.

 

For the rest I think you need to dump it and start over in terms of code. Are you trying to load all the records into a temporary gallery so that user's can enter Reasons and submit them?

 

If so, there are several problems with your code.

1) the Collect will only load one record, not all the records in the gallery

2) Since there is only one record in the temporary Gallery the Patch will only patch one record and the use of Default() will create a new record not patch an existing one.

That doesn't accomplish patching all the records you want to patch.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 
In the main list it looks like the column is just called 'Reason' not ATHReason.  So you should change that in the filter.

 

The reason is outside the Gallery as the header of the Gallery to represent what is beneath.

 

For the rest I think you need to dump it and start over in terms of code. Are you trying to load all the records into a temporary gallery so that user's can enter Reasons and submit them?

 

So let me start from the beginning what I did here to get the Gallery populated.

 

I have Employee List named as WHOSWHO as SharePoint List. I am Using Dropdown to get the data from this SP list into the Gallery (AHTBULKGallery) 

1. Header as Shift date and beneath label as DatePKT_1.SelectedDate 

2. Header as EID - ThisItem.EnterpriseID

3.Header LOB - ThisItem.Team

4. Header Queue- ddQueue_20.SelectedText.queue_name

5.Header Reason - AHTReason( is a foreign Text Input) is not the part of WHOSWHO SP List

6. Header Team Lead- ThisItem.TeamLead

7.Header OPS Lead- ThisItem.OpsLead

8. Header  Uploaded By - User().FullName

 

And then I am patching it to different SP List called AHTException.

 

Inside the Gallery of AHTBULKGallery

SortByColumns( Filter(WHOSWHO,TeamLead=ddTL_24.Selected.Result),"EnterpriseID",If(SortDescending1,Descending,Ascending))

 

What Code do I need to start with so that I can accomplish my overall Objective?

 

 

Let me try to clarify some things.

1) Galleries don't contain items.  They are a window to a data source or collection that display a filtered list of items contained in that data source or collection.

2) The Collect() statement you are using only adds ONE record to the AHTBULKGallery, which is actually a collection, not a Gallery.

3) Running a ForAll on that collection will only process that one record and add it to AHTException

4) AHTException has no connection to the original data source WhosWho.  

 

What is the Items and Data source setting for the main gallery in your display?  I don't see how it can be AHTBulkGallery because the Collection you create only has one record.  That is the data source you need to patch, not AHTException.

 

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 ,

 

So Let me go back to my Original Code where I have not used any collection.

I used two SP List

One is WHOSWHO to get the data in Gallery Named as AHT AHTBULKGallery. where I am using the dropdown to get the data in the Gallery. From WHOSWHO I am taking ThisItem.EnterpriseID, ThisItem.Team, ThisItem.TeamLead ThisItem.OpsLead

 

And rest Either I am taking from Dropdown List or hardcoded such as User().FullName

 

2nd AHTException is the SP List ( and I am Patching it back to AHTException SP List.)

 

Relation Betwenn the SharePoint List is EnterpriseID, Team, TeamLead, OpsLead there are in common for both the SP List

 

//Code on the Submit Button
Notify("Submitting your records...",NotificationType.Information);
ForAll(
AHTBULKGallery.AllItems,
If(
!IsBlank(AHTReason.Text),
Patch(
AHTException,
Defaults(AHTException),

{
Shiftdate:AHTSHIFTDATE.Text,
Enterprise_ID:AHTEID.Text,
LOB:AHTLOB.Text,
Queue:AHTQueue.Text,
Reason:AHTReason.Text,
'Requested By':AHTTLs.Text,
'Uploaded By':AHTUploadeBy.Text
}
)
)
);

Notify("All records has been submitted successfully!",NotificationType.Success);
Set(gvReset,true);
Set(gvReset,false)

 

//Code on the AHTBULKGallery.

SortByColumns( Filter(WHOSWHO,TeamLead=ddTL_24.Selected.Result),"EnterpriseID",If(SortDescending1,Descending,Ascending))

 

Now you let me know how to start with

As I explained in my last reply.  Galleries DO NOT contain data.  They display data that is stored in a data source or collection.  If the Items property of the gallery is set to 

SortByColumns( Filter(WHOSWHO,TeamLead=ddTL_24.Selected.Result),"EnterpriseID",If(SortDescending1,Descending,Ascending))

Then it is displaying a filtered list of data that is stored in WHOSWHO.  You can't patch() the gallery, you have to patch() the data source.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (91,087)