cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Poweruser1101
Helper II
Helper II

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

Hi All,

 

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @Poweruser1101 :

Please turn on "Formula Level Error Management" and try this formula:

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

 Best Regards,

Bof

View solution in original post

5 REPLIES 5
v-bofeng-msft
Community Support
Community Support

Hi @Poweruser1101 :

Please turn on "Formula Level Error Management" and try this formula:

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

 Best Regards,

Bof

@v-bofeng-msft Hey thank you for your responding.

I tried the above code by turning on the "Formula Level Error Management" but it didn't work for me.

After i turn on the above setting, my Save stops working. If I turn off the setting and only apply the code change you mentioned, still the code does not work. What could be the issue behind this?

Poweruser1101
Helper II
Helper II

@v-bofeng-msft Hey apologies i realised..the solution does work for me. It does save back the null values only after turning the setting on and applying the code.Only Issue is my formulas have stopped working. I have formula on one of the datacards - which is a sum of several other datacards -

 

Formula - 

Set in 'Default Property of DataCardValue of Datacard' -

Value(DataCardValue11.Text)+Value(DataCardValue24.Text)+Value(DataCardValue32.Text) +Value(DataCardValue40.Text)

 

Now the formula does not work and does show any value. Can you please think of anything which could be wrong?

Hi @Poweruser1101 :

Sorry, I’m not sure what your new request is. If my understanding is wrong, please point it out.

About  'Default Property of DataCardValue of Datacard'  .Could you tell me:

  • What is DataCardValue ?Is it a combo box control?
  • What is Datacard?What is its corresponding field? What is its data type?

Case1:If DataCardValue is a combo box, then its "Default" property does not work, you need to set its "DefaultSelectedItems" property.

Case2:If it is a data type problem, such as when the values of the textinput control are all empty, you want the value of "Value(DataCardValue11.Text)+Value(DataCardValue24.Text)+Value(DataCardValue32.Text) +Value(DataCardValue40.Text)" to be blank, Then you need to use this formula:

If(
  IsBlank(DataCardValue11.Text)&&IsBlank(DataCardValue24.Text)&&IsBlank(DataCardValue32.Text)&&IsBlank(DataCardValue40.Text),
  Blank(),
  Value(DataCardValue11.Text)+Value(DataCardValue24.Text)+Value(DataCardValue32.Text) +Value(DataCardValue40.Text)
)

Best Regards,

Bof

@v-bofeng-msft Thank you so much. I resolved the formula error too with your given suggestion.

 

IfError(

If(IsBlank('Test1 Sales Number_DataCardValue'.Text), 0, Value('Test1 Sales Number_DataCardValue'.Text)) +
If(IsBlank('Test2 Sales Number_DataCardValue'.Text), 0, Value('Test2 Sales Number_DataCardValue'.Text)) +
If(IsBlank('Test3 Sales Number_DataCardValue'.Text), 0, Value('Test3 Sales Number_DataCardValue'.Text)) +
If(IsBlank('Test4 Sales Number_DataCardValue'.Text), 0, Value('Test4 Sales Number_DataCardValue'.Text))

, ThisItem.'Stored Value of the field').

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,693)