cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ruchiga
Level: Powered On

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 RusselThomas
Microsoft

Re: Repeat and Blank Value Collection

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 RusselThomas
Microsoft

Re: Repeat and Blank Value Collection

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

ruchiga
Level: Powered On

Re: Repeat and Blank Value Collection

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 Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,890)