cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
moises_martinez
Frequent Visitor

Can I control properties of type number?

Hi everybody!

 

I have a custom visual with two properies of type number, Which are called Max and Min. How I can control Max is greater than Min when the user changes any of the values?

It's possible???

 

 

Thank in advance.

1 REPLY 1
itayrom
Resolver II
Resolver II

First, a few assumptions:

1. You created a "settings" object called "mySettings" to hold the min and max properties values.

2. You created a converter() function that, among other things, gets the min and max properties values and assigns them to mySettings.

3. In your enumerateObjectInstances() implementation, when handling the VisualObjectInstance object that has the min and max properties, you assign it with the corresponding values from mySettings.

 

The general idea is as follows:

In your converter() function, after you get the min and max values, you compare them to see if max is greater than min. If it is, than you assign their values to mySettings as usual. Otherwise, you set the invalid value to a valid one in mySettings(E.g, you can set min to max-1, or set max to min+1, or even check to see which one had its value changed and set it to its previous value, and so on...).

 

You can also notify the user about the error that occured by using the hostServices.setWarnings() method in your update() method. You can find many usage examples in the custom visuals github project(One example can be found in the funnelChart.ts file's update() implementation). This method pops up that annoying Power BI error message dialog.

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

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.

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.

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.