cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kelligan
Helper I
Helper I

NewForm and SubmitForm in a Gallery as if it were a Form

Hi Folks,
I am working on an app that has a tabbed interface and several forms that are conditionally visible. In order to set up a matrix or cross-tabulation format, I used a gallery on one of the tabs (see screenshot).

Gallery New and Update Problem 01.png

 

I have everything working except I need to utilize some icon functionality and am having trouble getting it to work.

I need to do two things that work just fine when applied to a form but do not work when applied to a gallery. When I click the New Icon, I want to do what NewForm(FormInformationTab_1) does but in the gallery. I tried loading the OnSelect property of the New icon with NewForm(GalleryMilestonesTab_1) and as you can imagine, that did not work. I also need to do a similar thing when submitting the new record... in the OnSelect property of my Submit button, I put SubmitForm(GalleryMilestonesTab_1).

Since I am actually updating multiple tabs, the working code is as follows...

NewForm(FormInformationTab_1)&&NewForm(FormStatusTab_1)&&NewForm(FormFinancialsTab_1)&&Select(TabGallery_1, 2, TabButton_1)

But the code I need the working equivalent of...

NewForm(FormInformationTab_1)&&NewForm(FormStatusTab_1)&&NewForm(GalleryMilestonesTab_1)&&NewForm(FormFinancialsTab_1)&&Select(TabGallery_1, 2, TabButton_1)

...also with the submit of the new item I need an equivalent of the following to work...

UpdateContext({popupvis:false});SubmitForm(FormInformationTab_1)&&SubmitForm(FormStatusTab_1)&&SubmitForm(GalleryMilestonesTab_1)&&SubmitForm(FormFinancialsTab_1)

The error appears when I reference the Gallery in a function designed for a form. Is there a workaround for this?

 

Thanks and Regards,

Patrick Kelligan

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Kelligan ,

The column name after 'DropdownGrantAward.Selected.' code depends on the dropdown's Items property. You can type 'DropdownGrantAward.Selected.' code and use the column name system recommends, or you can share the Item property and Value of dropdown, I will provide more accurate code.

 

To New function, as I said before, create a blank record, and bind it to the Items of Gallery, then save all control value to that blank record.

Please follow the steps to configure New, Edit and Save function

1. Set OnSelect of New button, create a blank record with only required column (e.g Title)

Set(VarItem,Patch('Quarterly Reports',Defaults('Quarterly Reports'), {Title:"Test"})); Set(VarMode,"New")

2. Set OnSelect of Edit button:

Set(VarMode,"Edit")

3. Modify Items property of Gallery:

If(VarMode="New",VarItem,VarMode="Edit",BrowseGalleryTab_1.Selected)

4. Modify OnSelect of Save button:

Patch('Quarterly Reports', If(VarMode="New",VarItem,VarMode="Edit",BrowseGalleryTab_1.Selected), {...})

 

Sik

View solution in original post

9 REPLIES 9
PowerAddict
Super User II
Super User II

Have you tried using Patch to submit the data from your collection? 

 

Something like: 

ForAll(Gallery.AllItems, Patch(DataSource, Defaults(DataSource), {Column1: ThisItem.Column1}))

 

Let me know if this works. 

 

---
If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

 

Thanks!

Hardit Bhatia

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

Hi @PowerAddict,

Thanks for the quick reply! I am very new to PowerApps and SharePoint online. Can you tell me how to apply this code? Does this apply to the NewForm procedure or the SubmitForm? I applied the following to the OnSelect of IconNewItem_1 and the error was in her last part ({Column1: ThisItem.Column1}). I am not sure what this should translate to in my case.

ForAll(GalleryMilestonesTab_1.AllItems, Patch('Quarterly Reports',Defaults('Quarterly Reports'), {Column1: ThisItem.Column1}))

Thanks for your assistance!

Patrick

 

 

Hi @Kelligan ,

 

I agree with @PowerAddict 's workaround, using ForAll and Patch function to save the gallery into sharepoint.

It seems that there are two data pickers and one dropdown in each gallery item, and I assume that column1 is related to BaseLine Date, Column2 is related to Latest Amended Date and Column3 is related to Actual/Expected.

ForAll(GalleryMilestonesTab_1.AllItems, Patch('Quarterly Reports',Defaults('Quarterly Reports'), {Column1: <BaseLine Date Picker>.SelectedDate, Column2: <Latest Amended Date Picker>.SelectedDate,  Column3: <Actual/Expected Combo box>.Selected.Value})) //Change to the real control names and column names

 

If you want to new a gallery like NewForm function, you can create some blank records in the collection, related to the Gallery Items property to these blank records, then it shows as a blank gallery.

Sik

Hi @v-siky-msft,

I see where the confusion is now. I used the gallery so that I could locate the date pickers and drop-downs anywhere on the screen I needed to (the cross-tabulation format) There is actually only one gallery item visible in that screenshot. Each of those 33 controls belongs to the same record. Will it work efficiently to just extend your code sample to include all of the 33 controls in the patch function?

 

Thanks!

Patrick

Hi @Kelligan ,

 

Do you mean all these 33 controls are all from the only one record and each control corresponds to a field of SharePoint list?

If so, there is no need to use ForAll function, just use Patch function directly to save all 33 control values to the specific record.

Try this:

Patch('Quarterly Reports',BrowseGalleryTab_1.Selected, {Column1: DatePicker1.SelectedDate, Column2:DatePicker2.SelectedDate,Column3: DropDown1.Selected.Value, ...})

Sik

Hi @v-siky-msft,


@v-siky-msft wrote:

Do you mean all these 33 controls are all from the only one record and each control corresponds to a field of SharePoint list?


Yes, that is correct.

 


@v-siky-msft wrote:

If so, there is no need to use ForAll function, just use Patch function directly to save all 33 control values to the specific record.

Try this:

Patch('Quarterly Reports',BrowseGalleryTab_1.Selected, {Column1: DatePicker1.SelectedDate, Column2:DatePicker2.SelectedDate,Column3: DropDown1.Selected.Value, ...})

Here is what I have come up with...

 

 

 

UpdateContext({popupvis:false});
SubmitForm(FormInformationTab_1)&&
SubmitForm(FormStatusTab_1)&&
SubmitForm(FormFinancialsTab_1)&&
Patch('Quarterly Reports',Defaults('Quarterly Reports'), 
{Grant Award Baseline Date - Term Sheet: <DatePickerGrantAwardBaseline>.SelectedDate, 
Period of Performance End Baseline Date - Term Sheet: <DatePickerPOPEndBaseline>.SelectedDate, 
NEPA Complete Baseline Date - Term Sheet: <DatePickerNEPACompleteBaseline>.SelectedDate, 
Preliminary Design Complete 30% Baseline Date - Term Sheet: <DatePickerPrelimDesignCompleteBaseline>.SelectedDate, 
Final Design Complete 100% Baseline Date - Term Sheet: <DatePickerFinalDesignCompleteBaseline>.SelectedDate, 
Right of Way Complete Baseline Date - Term Sheet: <DatePickerRighOfWayCompleteBaseline>.SelectedDate, 
PS&E-Bid-Ready Baseline Date - Term Sheet: <DatePickerPSnEBidReadyBaseline>.SelectedDate, 
Grant Funds 100% Obligated Baseline Date - Term Sheet: <DatePickerGrantFunds100ObligatedBaseline>.SelectedDate, 
Construction - Notice to Proceed Baseline Date - Term Sheet: <DatePickerConstructionNoticeToProceedBaseline>.SelectedDate, 
Construction - Begin Construction Baseline Date - Term Sheet: <DatePickerConstructionBeginBaseline>.SelectedDate, 
Project Ground Breaking Baseline Date - Term Sheet: <DatePickerProjectGroundBreakingBaseline>.SelectedDate, 
Construction - End Construction Baseline Date - Term Sheet: <DatePickerConstructionEndBaseline>.SelectedDate, 
Project Opening or Open to Traffic Baseline Date - Term Sheet: <DatePickerProjectOpeningBaseline>.SelectedDate, 
Project Ribbon Cutting Baseline Date - Term Sheet: <DatePickerProjectRibbonCuttingBaseline>.SelectedDate, 
Mode Site Visit Baseline Date - Term Sheet: <DatePickerModeSiteVisitBaseline>.SelectedDate, 
Grant Award Latest Amended Date: <DatePickerGrantAwardAmended>.SelectedDate, 
Period of Performance End Latest Amended Date: <DatePickerPOPEndAmended>.SelectedDate, 
NEPA Complete Latest Amended Date: <DatePickerNEPACompleteAmended>.SelectedDate, 
Preliminary Design Complete 30% Latest Amended Date: <DatePickerPrelimDesignCompleteAmended>.SelectedDate, 
Final Design Complete 100% Latest Amended Date: <DatePickerFinalDesignCompleteAmended>.SelectedDate, 
Right of Way Complete Latest Amended Date: <DatePickerRighOfWayCompleteAmended>.SelectedDate, 
PS&E-Bid-Ready Latest Amended Date: <DatePickerPSnEBidReadyAmended>.SelectedDate, 
Grant Funds 100% Obligated Latest Amended Date: <DatePickerGrantFunds100ObligatedAmended>.SelectedDate, 
Construction - Notice to Proceed Latest Amended Date: <DatePickerConstructionNoticeToProceedAmended>.SelectedDate, 
Construction - Begin Construction Latest Amended Date: <DatePickerConstructionBeginAmended>.SelectedDate, 
Project Ground Breaking Latest Amended Date: <DatePickerProjectGroundBreakingAmended>.SelectedDate, 
Construction - End Construction Latest Amended Date: <DatePickerConstructionEndAmended>.SelectedDate, 
Project Opening or Open to Traffic Latest Amended Date: <DatePickerProjectOpeningAmended>.SelectedDate, 
Project Ribbon Cutting Latest Amended Date: <DatePickerProjectRibbonCuttingAmended>.SelectedDate, 
Mode Site Visit Latest Amended Date: <DatePickerModeSiteVisitAmended>.SelectedDate, 
Grant Award Actual or Expected: <DropdownGrantAward>.Selected.Value, 
Period of Performance End Actual or Expected: <DropdownPOPEnd>.Selected.Value, 
NEPA Complete Actual or Expected: <DropdownNEPAComplete>.Selected.Value, 
Preliminary Design Complete 30% Actual or Expected: <DropdownPrelimDesignComplete>.Selected.Value, 
Final Design Complete 100% Actual or Expected: <DropdownFinalDesignComplete>.Selected.Value, 
Right of Way Complete Actual or Expected: <DropdownRighOfWayComplete>.Selected.Value, 
PS&E-Bid-Ready Actual or Expected: <DropdownPSnEBidReady>.Selected.Value, 
Grant Funds 100% Obligated Actual or Expected: <DropdownGrantFunds100Obligated>.Selected.Value, 
Construction - Notice to Proceed Actual or Expected: <DropdownConstructionNoticeToProceed>.Selected.Value, 
Construction - Begin Construction Actual or Expected: <DropdownConstructionBegin>.Selected.Value, 
Project Ground Breaking Actual or Expected: <DropdownProjectGroundBreaking>.Selected.Value, 
Construction - End Construction Actual or Expected: <DropdownConstructionEnd>.Selected.Value, 
Project Opening or Open to Traffic Actual or Expected: <DropdownProjectOpening>.Selected.Value, 
Project Ribbon Cutting Actual or Expected: <DropdownProjectRibbonCutting>.Selected.Value, 
Mode Site Visit Actual or Expected: <DropdownModeSiteVisit>.Selected.Value})

 

 

 

I applied this formula to a Submit button on a rectangle that I use as a submit confirmation popup. The tooltip error I get is "Expected operator. We expected an operator such as +, *, or & at this point in the formula." (sorry no screenshot of that... I am using VMWare having trouble getting screenshots of mouse-hover messages). When referencing the "...at this point in the formula", PowerApps does not seem to point to a location in the formula; or am I missing something?

 

The folks who created the source lists on this site used special characters in the field names such as /, &, %, etc... Could that be the issue, and if so, am I able to escape those special characters in this formula with single or double quotes?

 

Thanks so much, for your kind attention to this request for help!

 

Regards,

Patrick

 

EDIT:

I simplified the formula to include only one reference that did not contain any special characters and got the same error. I tried enclosing the column name in single and double quotes as well. Neither worked.

 

 

UpdateContext({popupvis:false});
SubmitForm(FormInformationTab_1)&&
SubmitForm(FormStatusTab_1)&&
SubmitForm(FormFinancialsTab_1)&&
Patch('Quarterly Reports',Defaults('Quarterly Reports'), 
{Project Ribbon Cutting Actual or Expected: <DropdownProjectRibbonCutting>.Selected.Value,})

 

 

It appears that I have an error in my syntax somewhere... Can you see anything I missed? Here is the error message from the 

OnSelect property box. I am not sure I understand it.

Gallery New and Update Problem 02.png

 

I tried referencing the column's internal as well as visible name...

 

//Internal column name (ProjectRibbonCuttingActual_x002fd) ERROR: The specified column 'ProjectRibbonCuttingActual_x002fd' does not exist. The function 'Patch' has some invalid arguments.
Patch('Quarterly Reports',Defaults('Quarterly Reports'), {ProjectRibbonCuttingActual_x002fd: <DropdownProjectRibbonCutting>.Selected.Value,})

//Visible column name (ProjectRibbonCuttingActual_x002fd) ERROR: I get a different error over each worrd in ther field name.
Patch('Quarterly Reports',Defaults('Quarterly Reports'), {Project Ribbon Cutting Actual or Expected:<DropdownProjectRibbonCutting>.Selected.Value,})

 

I even tried encoding the column name replacing the spaces with "%20" in case the system did not like the spaces. No Luck.

Thanks!

Hi @Kelligan ,

 

Sorry for not explaining it clearly.

In general, there is no need to enclose the control name by <>. 

If the column name has a special symbol, the column name should just be enclosed by single quotes.

Example:

'Grant Award Baseline Date - Term Sheet': DatePickerGrantAwardBaseline.SelectedDate

Sik

Hi @v-siky-msft,

That helped. The date picker references seem to be working now but I still get errors with the drop-down references. The properties box seems to have a problem with the use of "Selected.Value" when dealing with a drop-down control. I played around with it and it accepts, without error, "SelectedText" (no period). Does it make sense that this should be happening?

 

// No error...
Patch('Quarterly Reports', Defaults('Quarterly Reports'), {'Grant Award Actual or Expected': DropdownGrantAward.SelectedText})

// Error...
Patch('Quarterly Reports', Defaults('Quarterly Reports'), {'Grant Award Actual or Expected': DropdownGrantAward.Selected.Value})

 

Thanks and Regards,

Patrick

 

EDIT: I added the code and got it to run without error. I am unable to actually test the updating of the controls because of the other part of my original question... namely, "When I click the New Icon, I want to do what NewForm(FormInformationTab_1) does but in the gallery (GalleryMilestonesTab_1). I tried loading the OnSelect property of the New icon with NewForm(GalleryMilestonesTab_1) and as you can imagine, that did not work." Do you know how this can be accomplished?

 

Thanks!

Hi @Kelligan ,

The column name after 'DropdownGrantAward.Selected.' code depends on the dropdown's Items property. You can type 'DropdownGrantAward.Selected.' code and use the column name system recommends, or you can share the Item property and Value of dropdown, I will provide more accurate code.

 

To New function, as I said before, create a blank record, and bind it to the Items of Gallery, then save all control value to that blank record.

Please follow the steps to configure New, Edit and Save function

1. Set OnSelect of New button, create a blank record with only required column (e.g Title)

Set(VarItem,Patch('Quarterly Reports',Defaults('Quarterly Reports'), {Title:"Test"})); Set(VarMode,"New")

2. Set OnSelect of Edit button:

Set(VarMode,"Edit")

3. Modify Items property of Gallery:

If(VarMode="New",VarItem,VarMode="Edit",BrowseGalleryTab_1.Selected)

4. Modify OnSelect of Save button:

Patch('Quarterly Reports', If(VarMode="New",VarItem,VarMode="Edit",BrowseGalleryTab_1.Selected), {...})

 

Sik

View solution in original post

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 (2,946)