Hi,
I have a gallery and the form on the same screen. The form's Items property is Gallery.Selected.
The form's default mode is View and then it changes the DisplayMode depending on whether I need to add or edit it.
What I want is for the form to stay on the record that I just created after I submitted it.
I have a Save button with:
OnSelect = SubmitForm(FormName); ViewForm(FormName)
...but the form switches from that record to the record that was last selected in the gallery, even though the OnSuccess properties of the form are as follows:
OnSuccess = FormName.LastSubmit.Key
I am thinking that since the form in its DisplayView.Mode is tied to Gallery.Selected, it probably overrides the OnSuccess criteria of the form.
Any suggestions on how to keep the DisplayView.Mode on the record that was just submitted? Maybe Default property of the Gallery can be somehow adjusted?
Solved! Go to Solution.
Hi @kirillperian ,
Do you mean that:
1)this form could be used to edit, create and view?
2)if you select one item in the gallery, the form will be used to edit an existing record
3)if you click the add button, the form will be used to create a new item and display this new item in view mode after you submit this form?
If so, I've made a similar test for your reference:
1)the gallery's Items:
fruit11111
//my data source name
gallery's OnSelect:
EditForm(Form1);Set(mode,"edit")
2)insert an add button
set its OnSelect:
NewForm(Form1)
3)insert an edit form, set its data source:
fruit11111
set its Item:
If(mode="edit",Gallery1.Selected,Form1.LastSubmit)
insert a submit button, set its OnSelect:
SubmitForm(Form1);ViewForm(Form1);Set(mode,"view")
//then if you click the gallery, the form will change its mode to edit and display the selected item.
If you click the add button, the form will change its mode to new. If you submit the form, the form's mode will change to view and display the new item.
Best regards,
Either;
On the form item change it to FormName.LastSubmit
Or
Filter the Gallery to show the first item on top;
Sort(Datasource,Key, Descending)
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
Hi, @eka24 !
Thank you for your response!
My gallery has the correct order of sorting (and I don't want to change that) and if I change my form's Item property to LastSubmit, it will disconnect from the gallery and then if users are clicking on the gallery items, the form won't reflect the selection.
@kirillperian in that case, take two context variables - one is on gallery.selected and another one is on save. use both to switch your form modes.
varNewForm - true and varViewForm - false on Save button...similarly
varNewForm - false and varViewForm - true on gallery.selected
If the Gallery is well sorted, it means new items saved don't reflect immediately in the Gallery?
In that case change the Onsuccess to;
Set(Mylast,FormName.LastSubmit)
Then insert a button the can switch between the Gallery and the last Submit. Onselect of the button;
UpdateContext ({ChangeGal:!ChangeGal})
Then in the items of the form, change it to:
If(ChangeGal,MyLast, Gallery1.Selected)
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
------------
If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
Hi @kirillperian ,
Do you mean that:
1)this form could be used to edit, create and view?
2)if you select one item in the gallery, the form will be used to edit an existing record
3)if you click the add button, the form will be used to create a new item and display this new item in view mode after you submit this form?
If so, I've made a similar test for your reference:
1)the gallery's Items:
fruit11111
//my data source name
gallery's OnSelect:
EditForm(Form1);Set(mode,"edit")
2)insert an add button
set its OnSelect:
NewForm(Form1)
3)insert an edit form, set its data source:
fruit11111
set its Item:
If(mode="edit",Gallery1.Selected,Form1.LastSubmit)
insert a submit button, set its OnSelect:
SubmitForm(Form1);ViewForm(Form1);Set(mode,"view")
//then if you click the gallery, the form will change its mode to edit and display the selected item.
If you click the add button, the form will change its mode to new. If you submit the form, the form's mode will change to view and display the new item.
Best regards,