cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stapes
Post Prodigy
Post Prodigy

PowerApps App is displaying old values where actual values are Null

My Power Apps app is showing old values from a previous record where the current values are NULL.

This is totally unacceptable!

 

In all cases I have set Reset to true.

In all cases I have set Default Data to a formula like:

 

    If(!IsBlank(SelectedItem.ActualQtyDelivered)||!IsEmpty(SelectedItem.ActualQtyDelivered),

        SelectedItem.ActualQtyDelivered,

        "")

 

My record is loaded in the OnVisible action of the screen:

 

    UpdateContext({Tab1:true});
    If(!IsBlank(SelectedItem.thOurRef)||!IsEmpty(SelectedItem.thOurRef),
        ClearCollect(itemCollection,UpdateGoodsIn.Run(SelectedItem.thOurRef, SelectedItem.stCode)));
    If(IsBlank(SelectedItem.thOurRef)||IsEmpty(SelectedItem.thOurRef),
        Notify("No record selected", NotificationType.Error));
    UpdateContext({Updated:false});

How do I get it to display the correct values?

1 ACCEPTED SOLUTION

Accepted Solutions

What seems to have cured it is putting explicit resets in for each screen field.

 

Reset(txtActualQtyDelivered);Reset(dtDateDelivered);Reset(chbDeliveryAccepted);Reset(txtNumberOfPallets);Reset(chbPallletCondition);Reset(txtPalletType);Reset(txtBinLocation);Reset(txtProductStateTemp);Reset(dtExpiryDateChilled);Reset(dtExpiryDateFrozenFromChilled);Reset(txtConditionOfPack);Reset(chbVisualSpecCheck);Reset(chbRawMeatSpecCheck);Reset(chbHygeneOfDeviveryVehicle);Reset(chbCofACofCReceived);Reset(txtComments);Reset(txtWarehouseApprover);Reset(txtBatchCodes);Reset(chbExtraChecks);
Clear(itemCollection);
ClearCollect(itemCollection, ViewGoodsInDetailItemByID.Run(SelectedItem.ID)); Set(Selection, First(itemCollection));UpdateContext({Tab1:true});UpdateContext({Updated:false});

View solution in original post

9 REPLIES 9
v-siky-msft
Community Support
Community Support

Hi @stapes ,

Could you share more detail with your scenario? What is "SelectedItem"? How does it from?

If it is variable, your formulas will only show the selecteditem's value(previous). If you want to show current record value, you should pass the current record to Variable "SelectedItem". Please modify the Onvisble code as below: 

  UpdateContext({Tab1:true});
    If(!IsBlank(SelectedItem.thOurRef)||!IsEmpty(SelectedItem.thOurRef),
        ClearCollect(itemCollection,UpdateGoodsIn.Run(SelectedItem.thOurRef, SelectedItem.stCode)));
    If(IsBlank(SelectedItem.thOurRef)||IsEmpty(SelectedItem.thOurRef),
        Notify("No record selected", NotificationType.Error));
    UpdateContext({Updated:false});

    Set(SelectItems, First(itemCollection))

 

If this doesn't make sense or i misunderstand , please let me know and share more details.

Best regard,

Sik

 

Thank you v-siky-msft

This is driving me nuts.

 

SelectedItem is an Object that is passed from the previous screen.

All the other fields on my screen are populated from this object.

As you can see they are all populated.

Except that Actual Qty Delivered in this case is actually set to 0 (Zero) in the database!

Here is the data - from the Flow:

response-from-flow.PNG

 

screenshot.PNG

 

 

 

I have not solved this issue. Whether the correct values get displayed on screen seems to be totally random.

 

Here is another example.

1) Values displayed on screen:

POR029667.png

 

The values displayed for Number of Pallets, Pallet Type and stBinLocation are all garbage!

The flow picks up these values from the database correctly:

noPalletsPalletType.png

The Data Default Formula for these fields:

 

If(IsEmpty(SelectedItem.NumberOfPalletsReceived),"",!IsEmpty(SelectedItem.NumberOfPalletsReceived),SelectedItem.NumberOfPalletsReceived)

 

If(IsEmpty(SelectedItem.PalletType),"",!IsEmpty(SelectedItem.PalletType),SelectedItem.PalletType)

 

If(IsEmpty(SelectedItem.stBinLocation),"",!IsEmpty(SelectedItem.stBinLocation),SelectedItem.stBinLocation)

 

If I type anything at all in these fields in the edit screen, it corrects itself.

 

 

 

 

Hi @stapes ,

How did you get the SelectItem? You saved the return of flow into a collection, so you have first to assign the first record of collection to SelectItem variable. Just append Set(SelectItem, First(Collection)) to OnVisible property of Screen.

Then you can try to modify Defaults property of fields as below:

If(IsBlank(SelectedItem.NumberOfPalletsReceived),"", SelectedItem.NumberOfPalletsReceived)
If(IsBlank(SelectedItem.PalletType),"",SelectedItem.PalletType)
If(IsBlank(SelectedItem.stBinLocation),"",SelectedItem.stBinLocation)

Best regards,

Sik

I am getting my record in a previous screen. I get the collection here:

(Screen OnVisible property):

 

    Clear(detailCollection);
    Set(LoadingSpinnerVisibility,true);
    ClearCollect(detailCollection,GoodsInDetail.Run(SelectedOrder.thOurRef));
    Set(LoadingSpinnerVisibility,false);

 

That collection is the Datasource for a Gallery:

 

    SortByColumns(detailCollection,"QtyOS",Descending)

 

The rows in the gallery have a select icon. On Select:

 

    Set(gvLastScreen,Screen3_OrderDetailV2);
    Navigate(Screen4_OrderItemV2, None,{
    SelectedItem: galOrderDetails.Selected,
    OrderRef: SelectedOrder.thOurRef
    });

 

This way, SelectedItem is passed to the Item screen.

Hi v-siky-msft

 

I tried converting my form to use a new collection.

I am getting it at the OnVisible stage:

    Clear(itemCollection);
    ClearCollect(itemCollection, ViewGoodsInDetailItemByID.Run(SelectedItem.ID)); Set(Selection,

    First(itemCollection));UpdateContext({Tab1:true});UpdateContext({Updated:false});

 

My fields have this in the Default Data:

    If(IsEmpty(Selection.ActualQtyDelivered)||IsBlank(Selection.ActualQtyDelivered),

        0,

        !IsEmpty(Selection.ActualQtyDelivered),Selection.ActualQtyDelivered)

 

But it makes no difference. It is still displaying values from the last data I input on a completely different record!

 

What seems to have cured it is putting explicit resets in for each screen field.

 

Reset(txtActualQtyDelivered);Reset(dtDateDelivered);Reset(chbDeliveryAccepted);Reset(txtNumberOfPallets);Reset(chbPallletCondition);Reset(txtPalletType);Reset(txtBinLocation);Reset(txtProductStateTemp);Reset(dtExpiryDateChilled);Reset(dtExpiryDateFrozenFromChilled);Reset(txtConditionOfPack);Reset(chbVisualSpecCheck);Reset(chbRawMeatSpecCheck);Reset(chbHygeneOfDeviveryVehicle);Reset(chbCofACofCReceived);Reset(txtComments);Reset(txtWarehouseApprover);Reset(txtBatchCodes);Reset(chbExtraChecks);
Clear(itemCollection);
ClearCollect(itemCollection, ViewGoodsInDetailItemByID.Run(SelectedItem.ID)); Set(Selection, First(itemCollection));UpdateContext({Tab1:true});UpdateContext({Updated:false});

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,279)