cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ruchiga
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
RusselThomas
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
RusselThomas
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
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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

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

Top Solution Authors
Top Kudoed Authors
Users online (62,943)