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

Save syntax for updating a screen with 2 forms

Hello again,

 

When I create a new record from a screen with 2 forms, one form is read only and brings in the selected client's name I can save successfully with this syntax:

 

Patch('Client Workout',If('New workout'.Mode= FormMode.New ,Defaults('Client Workout'),'Edit workout'.Mode= FormMode.Edit, First('Client Workout')),'New workout'.Updates,{Client_x0020_Name:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Gallery2.Selected.ID, Value:Gallery2.Selected.'Client Name'}});Navigate('Client Profile and List of Workouts', ScreenTransition.None)

 

When I update this record a new one is created and none of the changes I made are saved with this syntax:

 

Patch('Client Workout',If('New workout'.Mode= FormMode.New ,Defaults('Client Workout'),'Edit workout'.Mode= FormMode.Edit, First('Client Workout')),'New workout'.Updates,{Client_x0020_Name:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Gallery2.Selected.ID, Value:Gallery2.Selected.'Client Name'}});Navigate('Client Profile and List of Workouts', ScreenTransition.None)

 

I am for sure using NewForm mode on the new form and EditForm on the edit form, so I'm not sure I need the If statements.

2 REPLIES 2
Highlighted
Community Support Team
Community Support Team

Re: Save syntax for updating a screen with 2 forms

Hi @trishmalloy ,

Could you please share a bit more about your scenario?

Could you please show more details about the 'Client Name' column in your 'Client Workout' SP List data source? Is it a LookUp type column?

 

Based on the formula you provided, I think there is something wrong with it. Within your Patch formula, the second argument is provided with a If function. If the 'New workout' form is in Edit mode, it would return First('Client Workout'), but the First('Client Workout') formula could only return the first record in your 'Client Workout' SP List. Do you only want to store single one record within your 'Client Workout' SP List?

 

I have made a test on my side, please consider take a try with the following workaround:

Modify your formula as below:

If(
   'New workout'.Mode= FormMode.New,
   Patch(        // Add new record 
         'Client Workout',
         Defaults('Client Workout'),
         'New workout'.Updates,
         {
           Client_x0020_Name:{'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Gallery2.Selected.ID, Value:Gallery2.Selected.'Client Name'}
        }
   ),
   Patch(        // update existing record
         'Client Workout',
         LookUp('Client Workout', 'Client Name'.Value = Gallery2.Selected.'Client Name'), // Modify here. Find the specific 'Client Workout' record you want to update using LookUp function
         'New workout'.Updates,
         {
           Client_x0020_Name:{'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:Gallery2.Selected.ID, Value:Gallery2.Selected.'Client Name'}
        }
   )
)

Note: I assume that you want to editing record in your 'Client Workout' list data source after you selected a specific 'Client Name' in your Gallery2.

 

Please find the specific record you want to update within your 'Client Workout' list using LookUp function. Please consider take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
trishmalloy
Level: Powered On

Re: Save syntax for updating a screen with 2 forms

@v-xida-msft 

 

I created some better documentation about the app I'm trying to create.  I'm hoping this will help you help me with the Save formula for creating a new record and for editing a record.  When I added the formula that you posted on Tuesday nothing happened.  The areas I need help with are in hot pink.  Does this help?  Please let me know if you need any more information!

 

SCREEN 1

 

Text input used for Search

 

SCREEN 2

 

Gallery2 (Select Client based on text input from screen 1)

 

Filter('Client Profile',StartsWith('Client Name', 'Search for Client'.Text))

 

SCREEN 3

 

1 form and 1 gallery.  Selected client’s profile named FormViewer1 and …

 

Gallery3 list of selected client’s workouts

 

Filter('Client Workout', Client_x0020_Name.Value = Gallery2.Selected.'Client Name')

 

From this screen a new workout can be created.

 

NewForm('New workout');Navigate('New Workout', ScreenTransition.None)

 

Client Profile and List of Workouts.PNG

 

The New Workout screen has 2 forms on it.  The bottom form is named New workout, the top form is named New workout – Name and is a read only field brought in from selecting a client from Gallery2.

 

Create new workout.PNG

I am not sure what the Save formula should be when a new record is created.

 

 

Back to SCREEN 3 where a client’s workout can be viewed and edited by selecting the right arrow

 

Select client workout.PNG

 

The bottom form name is View workout and the top form is named View workout - Name

view form with ability to edti.PNG

 

When the Edit icon is clicked it goes to Edit Client Workout screen where there are 2 forms.  The bottom form name is Edit workout and the top form name is Edit workout – Name.

 

I am not sure what the Save formula should be for editing a workout.

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.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

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 (9,501)