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

ID(Autonumber) in case of EditForm and NewForm?

I am dealing with table1.LastSubmit.ID, NewForm and submit data on two table to sql server.

so in case EditForm, it should take id(autonumber)(from table1) and saved it table2. in case  FormNew(table1) I am using table1.LastSubmit.ID which works fine. 

 

how do I do condition to apply if editform then take existing id from form(table1)  and incase of new records take table1.LastSubmit.ID

 

I am using SubmitForm; Patch(table2,deafults(table2,{id:table1.LastSubmit.ID}) works fine. but want to apply condition like above.

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User III
Super User III

Hi @sanrajbhar

 

The best way to test the whether a user is editing or adding a new record is to check the mode property of the form.

 

Your edit form will have an Item property, and this will be set to something like BrowseGallery1.Selected. You can call the ID property of this to retrieve the ID of the record that a user is editing. You code would look something like this:

 

SubmitForm; 
If(EditForm1.Mode = FormMode.Edit, 
   Patch(table2,Defaults(table2,{id:BrowseGallery1.Selected}), 
   Patch(table2,Defaults(table2,{id:table1.LastSubmit.ID})
)

View solution in original post

1 REPLY 1
timl
Super User III
Super User III

Hi @sanrajbhar

 

The best way to test the whether a user is editing or adding a new record is to check the mode property of the form.

 

Your edit form will have an Item property, and this will be set to something like BrowseGallery1.Selected. You can call the ID property of this to retrieve the ID of the record that a user is editing. You code would look something like this:

 

SubmitForm; 
If(EditForm1.Mode = FormMode.Edit, 
   Patch(table2,Defaults(table2,{id:BrowseGallery1.Selected}), 
   Patch(table2,Defaults(table2,{id:table1.LastSubmit.ID})
)

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

PA Community Call

Power Apps Community Call

Next call is happening on April 21st at 8a PST.

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (58,537)