cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
shaneOZ
Level 8

Lastsubmit to a collection in Editform

 

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
KroonOfficeSol
Level 10

Re: Lastsubmit to a collection in Editform

@shaneOZ

 

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

View solution in original post

8 REPLIES 8
KroonOfficeSol
Level 10

Re: Lastsubmit to a collection in Editform

@shaneOZ

 

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

View solution in original post

shaneOZ
Level 8

Re: Lastsubmit to a collection in Editform

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
Level 10

Re: Lastsubmit to a collection in Editform

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
shaneOZ
Level 8

Re: Lastsubmit to a collection in Editform

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))

shaneOZ
Level 8

Re: Lastsubmit to a collection in Editform

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

KroonOfficeSol
Level 10

Re: Lastsubmit to a collection in Editform

No create one formula instead of two.

If(condition, true , false)
shaneOZ
Level 8

Re: Lastsubmit to a collection in Editform

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
Level 10

Re: Lastsubmit to a collection in Editform

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

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,141)