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 / Lastsubmit to a collec...
Power Apps
Answered

Lastsubmit to a collection in Editform

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

 

Hi I cannot seem to make my columns keep their last value submitted

 

Ive created an app where i need the values to stay the same unless changed by the user, (The red arrows)

 

 

 

for forum.png

 

Every user uploads to the sharepoint database, if they are connected , they push the button it patches the data to sharepoint and if they are offline they get sent to a collection and a timer is used to check every 15seconds and the data is uploaded when they are reconnected

 

See syntax below

 

If(Connection.Connected, Patch('Haulage Operators Log', Defaults('Haulage Operators Log'),
{ Haul_x0020_Truck: HaulTruck_Dropdown.Selected,
Activity: ACT_Dropdown.Selected,
to: TO_Dropdown.Selected,
Pit: PIT_Dropdown.Selected,
From: From_Dropdown.Selected,
starthours: Value(DCV_starthours.Text),
finishhours: Value(DCV_finishhours.Text)
}));

If(!Connection.Connected, Collect(RD18COLLECTION,
{Haul_x0020_Truck: HaulTruck_Dropdown.Selected,
starthours: DCV_starthours.Text,
finishhours: DCV_finishhours.Text,
Assetid: HaulTruck_Dropdown.Selected,
Activity: ACT_Dropdown.Selected,
Pit: PIT_Dropdown.Selected,
to: TO_Dropdown.Selected,
From: From_Dropdown.Selected})
)

 

I cannot get the option Lastsubmit.column.id to work? it currently shows other previously entered data. 

 

EditForm1.LastSubmit.Activity.Value & 

EditForm1.LastSubmit.Activity.Id shows an error

 

Is there a work around to keep the same data as 95% of the time the data values are the same, i need the users to quickly submit the data and not manually select the columns everytime

 

I should also say it needs to be the last selected value from that user not the last submitted value of the database as other users could be going to a different location

 

Any help would be gladly appreciated.

 

Categories:
  • Verified answer
    KroonOfficeSol Profile Picture
    587 on at

    @Anonymous

     

    You use patch and not SubmitForm(). So there is no EditForm1.LastSubmit.Activity.Value because you don't submit any form at all.

     

    When you use Patch over a form, I would think you would be better of creating some controls on the canvas (instead of the form). Then OnChange off the controls you use UpdateContext() to store the selected value in a variable. Use this variable in your patch() formula. Then after the patch reset() only the controls which you want to be empty.

     

    Hope this helps.

     

    Paul

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Sorry im a little confused, 

     

    Do you mean the following syntax>? because it still shows previous entries?

     

    If(Connection.Connected, Patch('Haulage Operators Log', Defaults('Haulage Operators Log'),
    { Haul_x0020_Truck: HaulTruck_Dropdown.Selected,
    Activity: ACT_Dropdown.Selected,
    to: TO_Dropdown.Selected,
    Pit: PIT_Dropdown.Selected,
    From: From_Dropdown.Selected,
    starthours: Value(DCV_starthours.Text),
    finishhours: Value(DCV_finishhours.Text)
    }));
    If(!Connection.Connected, Collect(RD18COLLECTION,
    {Haul_x0020_Truck: HaulTruck_Dropdown.Selected,
    starthours: DCV_starthours.Text,
    finishhours: DCV_finishhours.Text,
    Assetid: HaulTruck_Dropdown.Selected,
    Activity: ACT_Dropdown.Selected,
    Pit: PIT_Dropdown.Selected,
    to: TO_Dropdown.Selected,
    From: From_Dropdown.Selected})
    ; UpdateContext({Haul_x0020_Truck: HaulTruck_Dropdown.Selected,
    Activity: ACT_Dropdown.Selected,
    to: TO_Dropdown.Selected,
    Pit: PIT_Dropdown.Selected,
    From: From_Dropdown.Selected,
    starthours: Value(DCV_starthours.Text),
    finishhours: Value(DCV_finishhours.Text)
    }))

  • KroonOfficeSol Profile Picture
    587 on at
    Oke, but this is strange isn't it, because you don't use the form to write. So I would think getting the last submitted from the form is not reliable.

    Btw, you do two times an if() formula. You can better use one an place the second patch in the false part.

    Paul
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi, I was able to get my data to stay using your advice however and (https://powerusers.microsoft.com/t5/General-Discussion/Cannot-Patch-Float-or-Number/td-p/54171) now everything works however there is a new problem haha (there always is, gotta love it) i just need the app to send multiple entries into the collection in case my users do not reach connection between each entry (it will happen), and to top it off im going to add a timer on the button so the users cannot quickly hit a double entry,

     

    But a huge thankyou, ill mark it as solved, the onselect code i used to change the app in canvas like you suggested is below for anyone interested.

     

    I.e.

     

    If(Connection.Connected, UpdateContext({DisableVar:true});
    Patch(
    'Haulage Operators Log',
    Defaults('Haulage Operators Log'),
    {
    to: Can_to.Selected,
    From: Can_From.Selected,
    Pit: Can_Pit.Selected,
    Activity:Can_Activity.Selected,
    Haul_x0020_Truck: Can_haul.Selected,
    starthours: Can_Starthours.Text,
    finishhours: Can_Finishhours.Text
    }
    );
    UpdateContext({ResetVar: true});
    UpdateContext({ResetVar:false});
    UpdateContext({DisableVar:false});
    Navigate(EditScreen1_1, ScreenTransition.None));

    If(!Connection.Connected, UpdateContext({DisableVar:true});
    Collect(
    RD18COLLECTION,
    {
    to: Can_to.Selected,
    From: Can_From.Selected,
    Pit: Can_Pit.Selected,
    Activity:Can_Activity.Selected,
    Haul_x0020_Truck: Can_haul.Selected,
    starthours: Can_Starthours.Text,
    finishhours: Can_Finishhours.Text
    }
    );
    UpdateContext({ResetVar: true});
    UpdateContext({ResetVar:false});
    UpdateContext({DisableVar:false});
    Navigate(EditScreen1_1, ScreenTransition.None))

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Do you mean i need to reverse the If(connection.connected and the if(!connection.connected around?  

  • KroonOfficeSol Profile Picture
    587 on at
    No create one formula instead of two.

    If(condition, true , false)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Gotcha 🙂

     

    If(Connection.Connected, UpdateContext({DisableVar:true});
    Patch(
    'Haulage Operators Log',
    Defaults('Haulage Operators Log'),
    {
    to: Can_to.Selected,
    From: Can_From.Selected,
    Pit: Can_Pit.Selected,
    Activity:Can_Activity.Selected,
    Haul_x0020_Truck: Can_haul.Selected,
    starthours: Can_Starthours.Text,
    finishhours: Can_Finishhours.Text
    }
    );
    UpdateContext({ResetVar: true});
    UpdateContext({ResetVar:false});
    UpdateContext({DisableVar:false});
    Navigate(EditScreen1_1, ScreenTransition.None),

    !Connection.Connected, UpdateContext({DisableVar:true});
    Collect(
    RD18COLLECTION,
    {
    to: Can_to.Selected,
    From: Can_From.Selected,
    Pit: Can_Pit.Selected,
    Activity:Can_Activity.Selected,
    Haul_x0020_Truck: Can_haul.Selected,
    starthours: Can_Starthours.Text,
    finishhours: Can_Finishhours.Text
    }
    );
    UpdateContext({ResetVar: true});
    UpdateContext({ResetVar:false});
    UpdateContext({DisableVar:false});
    Navigate(EditScreen1_1, ScreenTransition.None))

  • KroonOfficeSol Profile Picture
    587 on at

    No like this

    If(Connection.Connected
    	,Patch('Haulage Operators Log',
    		Defaults('Haulage Operators Log'),
    		{
    		to: Can_to.Selected,
    		From: Can_From.Selected,
    		Pit: Can_Pit.Selected,
    		Activity:Can_Activity.Selected,
    		Haul_x0020_Truck: Can_haul.Selected,
    		starthours: Can_Starthours.Text,
    		finishhours: Can_Finishhours.Text
    		}
    	)
    	,Collect(RD18COLLECTION,
    		{
    		to: Can_to.Selected,
    		From: Can_From.Selected,
    		Pit: Can_Pit.Selected,
    		Activity:Can_Activity.Selected,
    		Haul_x0020_Truck: Can_haul.Selected,
    		starthours: Can_Starthours.Text,
    		finishhours: Can_Finishhours.Text
    		}
    	)
    );
    UpdateContext({ResetVar: true}); 
    UpdateContext({ResetVar:false});
    // is above to Reset some of the fields? If Yes, then create a new button, add Reset() formulas on this control and call by Select(Button), make the button not visible.
    Navigate(EditScreen1_1, ScreenTransition.None)

     

    It's not necessary to block a control, because this is the case by default, as long as the formulas run.

     

    Hope this helps,

     

    Paul

     

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 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard