Reply
Highlighted
Level: Powered On
Posts: 20
Registered: ‎09-27-2017
Accepted Solution

Update a Variable to ThisItem after Submit form

I am trying to update a variable after submitting an edit form.  I am looking for something like "OnSuccess:UpdateContext({Variable:ThisItem})"  or "OnSuccess:UpdateContext({Variable:LookUp('[dbo].[Table]',ClientID=EditForm.LastSubmit.ClientID)})"

 

The ClientID is a required unique key in an Azure database.

 

I already have a variable that updates a display form with "OnSuccess:UpdateContext({Variable2:EditForm.LastSubmit})", but this language does not update the item which other parts of the app rely on.

 

Thanks for any help.


Accepted Solutions
Level: Powered On
Posts: 20
Registered: ‎09-27-2017

Re: Update a Variable to ThisItem after Submit form

I added an "If" statement to the onsuccess statement only updating the variable if the record was a new record.  This worked.  For some reason the update variable did not work when it could be either a new record or an existing record.

 

Thanks for the help

View solution in original post


All Replies
Level 10
Posts: 2,013
Registered: ‎11-07-2016

Re: Update a Variable to ThisItem after Submit form

I don't use forms, but your second proposed piece of code should work (except it may be slow but can probably be speeded up)

If you need to use the value in other screens of the app then you need to use a global variable like this:

OnSuccess = Set(Variable, LookUp('[dbo].[Table]',ClientID=EditForm.LastSubmit.ClientID))

If this is not what you are looking for, please be more specifc about the issue you are having.

Community Support Team
Posts: 4,391
Registered: ‎09-20-2016

Re: Update a Variable to ThisItem after Submit form

Hi @diannottismh,

 

Do you need any further help on this?

As @Meneghino suggested, please switch updatecontext() function to Set() function, if you would like teh variable to work under other screens.

For the function reference, please check:

Set() function in PowerApps

Understand variables in PowerApps

 

Regards,

Michael

Level: Powered On
Posts: 20
Registered: ‎09-27-2017

Re: Update a Variable to ThisItem after Submit form

I added an "If" statement to the onsuccess statement only updating the variable if the record was a new record.  This worked.  For some reason the update variable did not work when it could be either a new record or an existing record.

 

Thanks for the help