cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MihirY
Level: Powered On

Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

I am initializing some variables with UpdateContext method in OnVisible of the screen. What I am doing is, I am getting the values of the fields using LookUp method as below. 

UpdateContex({varColumnName:LookUp('DataSource', ID = (varCopyItem.ID), 'ColumnName')})

But this is sometimes working and sometimes not working (varColumnName value is blank). Every time I am getting varCopyItem.ID value properly. Usually with UpdatContext when I move to another screen, variable values should not be there but sometimes, when I comeback to this screen, values are still pertaining. I am so confused with this behavior

 

anyone is having this situation? 

 

8 REPLIES 8
MartinWoe
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

Hi,

unfortunately you have not mentioned your data source.

- Maybe some of the values you are fetching through the command, are beyond the set item limit? (e.g. 500 items)

- If this is not the case, check your app parameters, if you have set any experimental features that might have impact on that behavior...

- If you have the chance, try to ClearCollect the Data Source and do the lookup against the Collection

- As you are using Lookup, please check if the Data Source has multiple entries matching the ID, maybe some don't have a value in ColumName... Lookup always takes the first result.

MihirY
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

My data source is SharePoint. Some lists having more than 500 items. But I have modified below settings.

image.png

 

But thing is sometimes variables are having values and sometimes not. I don't understand this thing.

MartinWoe
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

have you checked the other points?

MihirY
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

Please find below points: 
Maybe some of the values you are fetching through the command, are beyond the set item limit? (e.g. 500 items)

> I have increased limit to 2000

- If this is not the case, check your app parameters, if you have set any experimental features that might have impact on that behavior...

  > Only enabled under experimental features was "Enable Formula bar result view" 

- If you have the chance, try to ClearCollect the Data Source and do the lookup against the Collection

> I have changed this now. Instead of Lookup from data source I am initializing with varCopyItem.'Column Name'

- As you are using Lookup, please check if the Data Source has multiple entries matching the ID, maybe some don't have a value in ColumName... Lookup always takes the first result.

> This is not valid in my case

MartinWoe
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

Where and how do you init 

varCopyItem.ID
MihirY
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

In my previous screen Gallery is there. so when item got selected then I am setting as 

Set(varCopyItem, ThisItem);
MartinWoe
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

Before you do 

UpdateContex({varColumnName:LookUp('DataSource', ID = (varCopyItem.ID), 'ColumnName')})

would you please try to do

 

ClearCollect(colDataSource, Filter('DataSource', ID = varCopyItem.ID))

And change your Command to 

UpdateContex({varColumnName: First(colDataSource).'ColumnName'})

 so in total exchange your expression by

ClearCollect(colDataSource, Filter('DataSource', ID = varCopyItem.ID));
UpdateContex({varColumnName: First(colDataSource).'ColumnName'})

If this doesn't work, you might check if colDataSource has any data - if not there is a problem with the source.

 

 

MihirY
Level: Powered On

Re: Formulas and variables with UpdateContext method are not working as expected in OnVisible screen

I have identified the problem. Problem is, I am updating the context variable in OnChange method of the datacards and dropdowns. I am calling the Patch function after submit the form to SP list in OnSuccess method. Because of submission, the datacard values, dropdowns are resetting to previous values. So latest changes to controls are not in effect. I have removed in OnChange method and implemented in different way which is working fine now. 

 

@MartinWoe thanks for your help.