Search code examples
powerappspowerapps-canvaspowerapps-modeldriven

embedded canvas app + Issue with patch not updating the null values


I have created an embedded canvas app in model driven CRM Form.

I am updating my crm form values through the embedded canvas app -

I added the below formula on "OnDataRefresh" property of "ModelDrivenFormIntegration" so that data is updated when i hit Save on CRM Form -

Patch('DataSourceName', ModelDrivenFormIntegration.Item,
{
   'Attribute 1' :Value(DataCardValue3.Text),
   'Attribute 2' :Value(DataCardValue4.Text),

}
);

This works fine when i update the value of the fields such as from '600' to '700'. However the issue arises when i remove the values from the field such as from ''600" to blank " ". When the field value is blank, it does not update the ModelDrivenFormIntegration.Item and shows the previous value again as soon as i hit Save.

Also tried turning on "Formula Level Error Management", it did not work, also with this setting on my formulas stopped working

Kindly suggest any help would be appreciated.


Solution

  • That is because PowerApps dont recognise your "" as a Null or Empty Value like you expect it.

    As an Microsoft Post mentioned you have to activate Experimental Features for writing NULL Values to your Database.

    Edit:
    Okay so after reading some threads Patch with NULL resolving into Error that the new Value isn't updated, some recommend to change the Function from PATCH() to UPDATEIF()

    UpdateIf(
             ValueList, 
             LookUp(ValueList, PrimaryKeyColumn = "A specific value"), /* <-- Use LookUp formula to find the specific record you want to update */ 
             {NullValueColumn = 1}
    )
    

    I'm refering to the Documentation of UPDATE and UPDATEIF