Forum Discussion

Nazeer's avatar
Nazeer
Cloud Apps
03-14-2022

Reading Widget value to Edit script

Hi Team,

I am new here.

I am trying to read the value of a widget to the Edit script and trying to customize the widget based on data value.

For example, if I have an indicator or a smart label widget and could see a number or value in it. How can I use that value in the Edit script to customize widgets based on the value I get.

 

Naz

2 Replies

Replies have been turned off for this discussion
  • Hi Nazeer,
    For indicators you can use something like this:

    widget.on('processresult', function (e, ev) {
    	console.log(ev.result)
          console.log(e.indicatorInstance)
    });

    First console log will return basic informations like values, title, etc.
    Second one will return more advance properties, like styling of each element.
    Now, depending on what you would like to achive, you can use simple if statment and change for example font color of indicator label.

    widget.on('processresult', function (e, ev) {
        var options = {
            title: {
                fontWeight: 'bold',
                color: 'green'
            }
        }
    
        if (ev.result.value.data > x) e.indicatorInstance.setOptions('numericSimple', options);
    
    });

     
    Alek