cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Repeat and Blank Value Collection

What's another way other than writing every line 25 times? Any ideas?

If the value of Hours is blank, this should not go to the BACollect or SPList. How?

 

ClearCollect(BACollect,
{BU: DDBU.Selected.Value,Country:ddCountry.Selected.Value,Hours: Value(txtHour.Text)},
{BU: DDBU_1.Selected.Value,Country:ddCountry_1.Selected.Value,Hours: Value(txtHour_1.Text)},
{BU: DDBU_2.Selected.Value,Country:ddCountry_2.Selected.Value,Hours: Value(txtHour_2.Text)},
...
...
...
...

);

ForAll(BACollect,Patch('SPList',
Defaults('SPList'),
{
BU: {Value:BU, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Country: {Value:Country, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Hours: Hours
}
))

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft
Microsoft

Hi @ruchiga ,

That looks like a lot of hard work Smiley Wink

I assume you want to add some logic to the collection to exclude Blank() hours - and want to avoid having to add that logic to each line.  If I'm correct, just wrap your collection in a filter as part of the ForAll Patch - something like this;

ForAll(
          Filter(BACollect, !IsBlank(Hours)),
Patch('SPList',
Defaults('SPList'),
{
BU: {Value:BU, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Country: {Value:Country, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Hours: Hours
}
))

Hope this helps,

RT

View solution in original post

2 REPLIES 2
Microsoft
Microsoft

Hi @ruchiga ,

That looks like a lot of hard work Smiley Wink

I assume you want to add some logic to the collection to exclude Blank() hours - and want to avoid having to add that logic to each line.  If I'm correct, just wrap your collection in a filter as part of the ForAll Patch - something like this;

ForAll(
          Filter(BACollect, !IsBlank(Hours)),
Patch('SPList',
Defaults('SPList'),
{
BU: {Value:BU, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Country: {Value:Country, '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"},
Hours: Hours
}
))

Hope this helps,

RT

View solution in original post

I will get back to you shortly about blank() today.

 

I have about 50 controls. I don't want to copy and paste and change the number like the below example. What's another way other than copying/pasting and changing 25 times? Is there any easy code for this like for loop? 

 

ClearCollect(BACollect,
{BU: DDBU.Selected.Value,Country:ddCountry.Selected.Value,Hours: Value(txtHour.Text)},
{BU: DDBU_1.Selected.Value,Country:ddCountry_1.Selected.Value,Hours: Value(txtHour_1.Text)},
{BU: DDBU_2.Selected.Value,Country:ddCountry_2.Selected.Value,Hours: Value(txtHour_2.Text)},
...
...
...
...

);

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (60,815)