cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sunithav
Helper IV
Helper IV

Update Gallery Items based on drop down list control selected value

Hi Team,

 

I have gallery which is tied to a SharePoint list. It has a drop down list control in each row. If drop down list status is set to "Yes", two fields have to updated in SharePoint list and if drop down list status is set to "No"/"No-Not Available"/"No-Not Applicable", four fields have to updated in SharePoint list.

 

I tried the following expression. The second expression does not get executed at all. Could someone guide me on this please?

 

ForAll(Filter(gallery.AllItems, "No" in ddlStatus.Selected.Value),
UpdateIf(
'DataSource', ID = Value(lblItemID.Text),
{'Column1': "Text"}
)
);ForAll(Filter(gallery.AllItems, ddlStatus.Selected.Value = "Yes"),
UpdateIf(
'DataSource', ID = Value(ItemID.Text),
{'Column1': "Text"', 'Column2': 'Column3': "Text",'Column4': "Text"}
)
)

 

Thanks,

SV

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @sunithav :

I've made a test but it worked well on my side:

1\My data source:

1.JPG

2\Add a gallery(gallery) and set it's items property to:

DataSource

3\Add a label control(lblItemID) into this gallery and set it's text property to

ThisItem.ID

4\Add a combobox(ddlStatus) into this gallery and set it's items property to

["Yes","No","No-Not Applicable","No-Not Available"]

5\Add a button control and set it's OnSelect proeprty to(I noticed that the formula you provided may have some errors, I have marked them in red):

 

ForAll(Filter(gallery.AllItems, "No" in ddlStatus.Selected.Value),
UpdateIf(
'DataSource', ID = Value(lblItemID.Text),
{'Column1': "Text"}
)
);ForAll(Filter(gallery.AllItems, ddlStatus.Selected.Value = "Yes"),
UpdateIf(
'DataSource', ID = Value(lblItemID.Text),
{'Column1': "Text", 'Column2': "Text",'Column3': "Text",'Column4': "Text"}
)
)

36.gif

In addition,you can also try this formula to submit:

ForAll(
  gallery.AllItems,
      If(
          "No" in ddlStatus.Selected.Value,
          UpdateIf('DataSource', ID = Value(lblItemID.Text),{'Column1': "Text"}),
          "Yes" in ddlStatus.Selected.Value,
          Patch('DataSource', LookUp('DataSource',ID = Value(lblItemID.Text)),{Column1: "Text", Column2: "Text",Column3: "Text",Column4: "Text"})
       )
)

Or

ForAll(Filter(gallery.AllItems, "No" in ddlStatus.Selected.Value),
UpdateIf(
'DataSource', ID = Value(lblItemID.Text),
{'Column1': "Text"}
)
);ForAll(Filter(gallery.AllItems, ddlStatus.Selected.Value = "Yes"),
Patch(
'DataSource', LookUp('DataSource',ID = Value(lblItemID.Text)),
{Column1: "Text", Column2: "Text",Column3: "Text",Column4: "Text"}
)
)

These formulas also worked well on my side

Best Regards,

Bof

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

Hi @sunithav 

Please provide a screenshot of your gallery.  I cannot tell from your description what you are trying to do.  

Hi @Drrickryp ,

 

Thanks for checking this post. Here is the screenshot of the gallery which is connected to a SP list. There is a drop down list in the gallery with items ["Yes","No","No-Not Applicable","No-Not Available"]. If drop down list status is set to "Yes", save first field value in SharePoint list and if drop down list status is set to "No"/"No-Not Available"/"No-Not Applicable", save both field values in SharePoint list on Save button click.  

 

sunithav_0-1610341233736.png

Thanks,

SV

v-bofeng-msft
Community Support
Community Support

Hi @sunithav :

I've made a test but it worked well on my side:

1\My data source:

1.JPG

2\Add a gallery(gallery) and set it's items property to:

DataSource

3\Add a label control(lblItemID) into this gallery and set it's text property to

ThisItem.ID

4\Add a combobox(ddlStatus) into this gallery and set it's items property to

["Yes","No","No-Not Applicable","No-Not Available"]

5\Add a button control and set it's OnSelect proeprty to(I noticed that the formula you provided may have some errors, I have marked them in red):

 

ForAll(Filter(gallery.AllItems, "No" in ddlStatus.Selected.Value),
UpdateIf(
'DataSource', ID = Value(lblItemID.Text),
{'Column1': "Text"}
)
);ForAll(Filter(gallery.AllItems, ddlStatus.Selected.Value = "Yes"),
UpdateIf(
'DataSource', ID = Value(lblItemID.Text),
{'Column1': "Text", 'Column2': "Text",'Column3': "Text",'Column4': "Text"}
)
)

36.gif

In addition,you can also try this formula to submit:

ForAll(
  gallery.AllItems,
      If(
          "No" in ddlStatus.Selected.Value,
          UpdateIf('DataSource', ID = Value(lblItemID.Text),{'Column1': "Text"}),
          "Yes" in ddlStatus.Selected.Value,
          Patch('DataSource', LookUp('DataSource',ID = Value(lblItemID.Text)),{Column1: "Text", Column2: "Text",Column3: "Text",Column4: "Text"})
       )
)

Or

ForAll(Filter(gallery.AllItems, "No" in ddlStatus.Selected.Value),
UpdateIf(
'DataSource', ID = Value(lblItemID.Text),
{'Column1': "Text"}
)
);ForAll(Filter(gallery.AllItems, ddlStatus.Selected.Value = "Yes"),
Patch(
'DataSource', LookUp('DataSource',ID = Value(lblItemID.Text)),
{Column1: "Text", Column2: "Text",Column3: "Text",Column4: "Text"}
)
)

These formulas also worked well on my side

Best Regards,

Bof

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,711)