So i was struggling how I can solve my issue:
I have a Screen with multiple forms that interact with one Sharepoint list.
I already made the destinction if it's a new form or edit form to adda new item or edit an existing one.
However when i save a new item and don't close the form and make changes and save again it will always create new records instead of editing the first item created.
I was wondering if there is a way how to switch from new to the edit mode once i created a new record?
I tried to add this line after saving but it had no effect:
Set(SPFormMode;Edit);
The simple solution would be to hide the form once new item is added but i like to learn something new.
Thanks for your help
Solved! Go to Solution.
Hi @Lephas ,
You could save the SharePointIntegration.Selected item (if you are customizing forms) or Gallery.Selected item (if you are creating apps) as well as the updated item into a variable, and set the Item property of all the forms to be this variable, then when using EditForm(YourForms) all the forms will have all the default values of updated most recently.
1\ OnVisibel of the Screen:
Set(varItem, SharePointIntegration.Selected.ID)
or OnSelect of the Gallery arrow icon:
Set(varItem, Gallery.Selected.ID)
2\ Save last submitted item ID into the variable after patching:
If ('SharePointList'.Mode = FormMode.New;
Set(varItem, Patch(
'SharePointList';
Defaults('SharePointList');
'Form1'.Updates;
Form2.Updates;
Form3.Updates;
Form4.Updates;
{
'Workflow Status': {Value:"Draft"}
}
).ID;;
Notify("The Changes have been saved";NotificationType.Success;2000);;
EditForm('Form1');;
EditForm(Form2);;
EditForm(Form3);;
EditForm(Form4);
//Else
Patch(
'SharePointList';
ThisItem;
'Form1'.Updates;
Form2.Updates;
Form3.Updates;
Form4.Updates
);;
Notify("The Changes have been saved";NotificationType.Success;2000)
)
So you could find Set(variable, Patch().ID) could retrieve the newly created item ID after patching.
3\ Set Item of all the forms to:
LookUp(SPlist, ID = varItem)
Hope this helps.
Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
You need to put
EditForm(Form1)
in the OnSuccess property of your form. Where Form1 is replaced with the name of your form.
This helps but if I do that i am in a edit mode, but there doesn't seem to be a loaded item with it.
Is there some way how i can call up the item in the edit mode?
Here is my current code:
If ('SharePointList'.Mode = FormMode.New;
Patch(
'SharePointList';
Defaults('SharePointList');
'Form1'.Updates;
Form2.Updates;
Form3.Updates;
Form4.Updates;
{
'Workflow Status': {Value:"Draft"}
}
);;
Notify("The Changes have been saved";NotificationType.Success;2000);;
EditForm('Form1');;
EditForm(Form2);;
EditForm(Form3);;
EditForm(Form4);
//Else
Patch(
'SharePointList';
ThisItem;
'Form1'.Updates;
Form2.Updates;
Form3.Updates;
Form4.Updates
);;
Notify("The Changes have been saved";NotificationType.Success;2000)
)
Hi @Lephas ,
You could save the SharePointIntegration.Selected item (if you are customizing forms) or Gallery.Selected item (if you are creating apps) as well as the updated item into a variable, and set the Item property of all the forms to be this variable, then when using EditForm(YourForms) all the forms will have all the default values of updated most recently.
1\ OnVisibel of the Screen:
Set(varItem, SharePointIntegration.Selected.ID)
or OnSelect of the Gallery arrow icon:
Set(varItem, Gallery.Selected.ID)
2\ Save last submitted item ID into the variable after patching:
If ('SharePointList'.Mode = FormMode.New;
Set(varItem, Patch(
'SharePointList';
Defaults('SharePointList');
'Form1'.Updates;
Form2.Updates;
Form3.Updates;
Form4.Updates;
{
'Workflow Status': {Value:"Draft"}
}
).ID;;
Notify("The Changes have been saved";NotificationType.Success;2000);;
EditForm('Form1');;
EditForm(Form2);;
EditForm(Form3);;
EditForm(Form4);
//Else
Patch(
'SharePointList';
ThisItem;
'Form1'.Updates;
Form2.Updates;
Form3.Updates;
Form4.Updates
);;
Notify("The Changes have been saved";NotificationType.Success;2000)
)
So you could find Set(variable, Patch().ID) could retrieve the newly created item ID after patching.
3\ Set Item of all the forms to:
LookUp(SPlist, ID = varItem)
Hope this helps.
Best regards,
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.
Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.