cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cubist
Advocate II
Advocate II

Is this how update and persistProperties are supposed to work?


In what ways do update and persistProperties affect or trigger each other?  

[custom visual question] 


 Two specific questions are:

 

1)  Is this assumption correct?

Calling persistProperties triggers and update event, and from within the triggered event handler, calling VisualSettings.parse should always return results that include the new property value set during the perist call. 

 

This seems like what is supposed to happen, however I notice in some cases the actual behaviour is different or odd/unusual.  It seems either my understanding is incorrect, or there are exceptions where this does not happen.

 

2)  What is the expected behaviour of merge and replace for the persistProperties method? 

For example, these points are not clear:

  • When a property already exists: How is merge different from replace?  If the prop exists, does merge act identically and replace the property, or ignore it?
  • What a property does not exist:  How is merge different from replace?  If the prop does not exist, do they act identically and simply save the new property?

Any comments are appreciated, thank you.

 

3 REPLIES 3
v-viig
Community Champion
Community Champion

Hello @Cubist,

 

  1. Yes, you're correct. Calling persistProperties always triggers the update method. The argument of update method contains the up dated value that has been set by using persistProperties. What for do you use persistProperties?
  2. The merge operation merges the existing properties and the new properties. The replace operation removes the existing properies and saves the new properties. If properties don't exist persistProperties just saves the new properties.

 

Please let me know if you any further questions.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Thank you, I will mark you answer correct.  One more question please:

 

>>What for do you use persistProperties?

 

Because I have an input field on the visual, that the user can type directly into.  When the user types a value into an input field on my visual, isn't this the only way to save the value?

 

Thank you -

v-viig
Community Champion
Community Champion

@Cubist

 

There's no another way to keep users' input in such cases.

You should use persistProperties.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Kudoed Authors