web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Save syntax for updati...
Power Apps
Unanswered

Save syntax for updating a screen with 2 forms

(0) ShareShare
ReportReport
Posted on by 415

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.

Categories:
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    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,

  • trishmalloy Profile Picture
    415 on at

    @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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 221 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 120

Last 30 days Overall leaderboard