cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Collection not updating null values

Hi All,

 

I have a collection which is not updating null values.

It seems this is a known limitation of powerapps and I have gone through earlier posts where a workaround to set the null field to "" in the collection before patching is suggested.

 

I have 3 values which have null values in collection. Out of these only one value is showing the updated value (after I set it to null), the other two merely get set to null in the first iteration and then get updated with  new non null value after I re-run the code.

 

The code that has been written is exactly the same, which makes me wonder what is the issue here.

 

The piece of code is:

 

UpdateIf(
WellDataCollection,
WellID = WellSearchResultsGallery.Selected.WellID && IsBlank(ContractorName),
{ContractorName: " "}
);
UpdateIf(
WellDataCollection,
WellID = WellSearchResultsGallery.Selected.WellID && IsBlank(DirectionalCompany),
{DirectionalCompany: " "}
);
UpdateIf(
WellDataCollection,
WellID = WellSearchResultsGallery.Selected.WellID && IsBlank(RigName),
{RigName: " "}
);

 

Update(
WellDataCollection,
First(
Filter(
WellDataCollection,
WellID = WellSearchResultsGallery.Selected.WellID
)
),
{
WellID: WellSearchResultsGallery.Selected.WellID,
APINumber: APIDCValue.Text,
CommonWellName: Trim(Upper(CWNDCValue.Text)),
OfficialWellName: Trim(Upper(CWNDCValue.Text)),
Operator: OperatorComboBox.Selected.Result,
OperatorId: GUID(
LookUp(
WellDataCollection,
Operator = OperatorComboBox.Selected.Result,
OperatorId
)
),
ContractorName: ContractorComboBox.Selected.Result,
RigConfigID: GUID(
LookUp(
Filter(
WellDataCollection,
ContractorName = ContractorComboBox.Selected.Result
),
RigName = RigComboBox.Selected.Result,
RigConfigID
)
),
RigName: RigComboBox.Selected.Result,
DirectionalCompany: DirCompComboBox.Selected.DirectionalCompanyName,
DirectionalCompanyId: Value(DirCompComboBox.Selected.DirectionalCompanyID),
SpudDate: DateAdd(
DateValue1.SelectedDate,
-TimeZoneOffset(DateValue1.SelectedDate),
Minutes
),
LastUpdatedBy: User().FullName,
LastUpdated: Now(),
SystemListCodeValuesID_DIRTYP: LookUp(
WellProfileCollection,
ListDesc = WellProfileDropdown.Selected.Result,
SystemListCodeValueId
),
NewSpudDate: DateValue1.SelectedDate
}
);
SaveData(
WellDataCollection,
"WellDataCache"
);

 

Any idea why this is happening? All of them - Directional Company, Contractor, Rig are combo boxes with value listing in them.

 

Thanks,

AShep

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to update the column with Nulll value within your Collection?

 

Actually, it is an known issue within PowerApps, please check my response within the following thread:

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/Patch-Problem-Existing-data-updated-new-data-not-written-to/m-p/158677/highlight/false#M2302

 

Based on the formula that you mentioned, I think there is something wrong with it. I think it is not necessary to set the null field to "" in the collection before patching is suggested.

 

As an fixed solution, I think the UpdateIf function could achieve your needs. Please consider modify your formula as below:

 

UpdateIf(                   /* <-- Modify your formula here */
        WellDataCollection,
        WellID = WellSearchResultsGallery.Selected.WellID,
       {
       WellID: WellSearchResultsGallery.Selected.WellID,
       APINumber: APIDCValue.Text,
       CommonWellName: Trim(Upper(CWNDCValue.Text)),
       OfficialWellName: Trim(Upper(CWNDCValue.Text)),
       Operator: OperatorComboBox.Selected.Result,
       OperatorId: GUID(LookUp(WellDataCollection,Operator = OperatorComboBox.Selected.Result,OperatorId)),
       ContractorName: ContractorComboBox.Selected.Result,
       RigConfigID: GUID(LookUp(Filter(WellDataCollection,ContractorName = ContractorComboBox.Selected.Result), RigName = RigComboBox.Selected.Result, RigConfigID)),
       RigName: RigComboBox.Selected.Result,
       DirectionalCompany: DirCompComboBox.Selected.DirectionalCompanyName,
       DirectionalCompanyId: Value(DirCompComboBox.Selected.DirectionalCompanyID),
       SpudDate: DateAdd(DateValue1.SelectedDate,-TimeZoneOffset(DateValue1.SelectedDate),Minutes),
       LastUpdatedBy: User().FullName,
       LastUpdated: Now(),
       SystemListCodeValuesID_DIRTYP: LookUp(WellProfileCollection,ListDesc = WellProfileDropdown.Selected.Result,SystemListCodeValueId),
       NewSpudDate: DateValue1.SelectedDate
      }
);
SaveData(WellDataCollection, "WellDataCache")

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Do you want to update the column with Nulll value within your Collection?

 

Actually, it is an known issue within PowerApps, please check my response within the following thread:

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/Patch-Problem-Existing-data-updated-new-data-not-written-to/m-p/158677/highlight/false#M2302

 

Based on the formula that you mentioned, I think there is something wrong with it. I think it is not necessary to set the null field to "" in the collection before patching is suggested.

 

As an fixed solution, I think the UpdateIf function could achieve your needs. Please consider modify your formula as below:

 

UpdateIf(                   /* <-- Modify your formula here */
        WellDataCollection,
        WellID = WellSearchResultsGallery.Selected.WellID,
       {
       WellID: WellSearchResultsGallery.Selected.WellID,
       APINumber: APIDCValue.Text,
       CommonWellName: Trim(Upper(CWNDCValue.Text)),
       OfficialWellName: Trim(Upper(CWNDCValue.Text)),
       Operator: OperatorComboBox.Selected.Result,
       OperatorId: GUID(LookUp(WellDataCollection,Operator = OperatorComboBox.Selected.Result,OperatorId)),
       ContractorName: ContractorComboBox.Selected.Result,
       RigConfigID: GUID(LookUp(Filter(WellDataCollection,ContractorName = ContractorComboBox.Selected.Result), RigName = RigComboBox.Selected.Result, RigConfigID)),
       RigName: RigComboBox.Selected.Result,
       DirectionalCompany: DirCompComboBox.Selected.DirectionalCompanyName,
       DirectionalCompanyId: Value(DirCompComboBox.Selected.DirectionalCompanyID),
       SpudDate: DateAdd(DateValue1.SelectedDate,-TimeZoneOffset(DateValue1.SelectedDate),Minutes),
       LastUpdatedBy: User().FullName,
       LastUpdated: Now(),
       SystemListCodeValuesID_DIRTYP: LookUp(WellProfileCollection,ListDesc = WellProfileDropdown.Selected.Result,SystemListCodeValueId),
       NewSpudDate: DateValue1.SelectedDate
      }
);
SaveData(WellDataCollection, "WellDataCache")

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Hi 

 

This worked! Thanks so much!

Instead of UpdateIf, I had Patch statement in my original code. Then after reading on forums, I realized that Patch does not update null values and needs to be initialized with "".

It never occured to me that UpdateIf would solve the issue.

 

Thanks

--AShep

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,334)