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

Is it possible to change the Formmode to Edit while i am in New mode?

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-jefferni
Community Support
Community Support

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.

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

@Lephas 

You need to put 

EditForm(Form1)

 in the OnSuccess property of your form. Where Form1 is replaced with the name of your form. 

Lephas
Helper I
Helper I

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)
)
v-jefferni
Community Support
Community Support

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.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,667)