Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Mobile Operator

IExtensionsUI​.SetData(ControlPropertyBag)

  • Last UpdatedMar 23, 2017
  • 2 minute read

This API updates the properties of the controls (for example, visible) on control events (for example, onchange).

Parameters

  • ControlPropertyBag: Contains the lua table with key and value properties to be updated.

    • Key: ID of the control.

    • Value: A lua table with the following properties:

      • Key: Property name

      • Value: Property value

Example: Updating Single Control

The below example describes how to consume the parameters, populate other control properties, and call back the Extension UI, using SetData API, to update the property values accordingly. In this example, it is updating the States of the selected Country.

function OnCountryChange(id,controlData)

-- access the id of the control

IExtensionsLog.Log(id,"INFO")

-- access the selected value of the control

local controlValue = controlData['selectedvalue']

--populate the states of the selected country

local states = {}

states1[1] ='state1'

states1[2] ='state2'

states1[3] ='state3'

--create the property bag table to update each property with value along with controlid

local controlPropertyBag ={}

local dropdownControl2PropertyBag = {}

dropdownControl2PropertyBag['Data'] = states

dropdownControl2PropertyBag['Visible'] = true

controlPropertyBag['D2'] = dropdownControl2PropertyBag-- the key should be id of the control

IExtensionsUI.SetData(controlPropertyBag) -- call back Extension UI to update the relevant properties

end

Example: Updating Multiple Controls

In the following example, we want to update the state dropdown data, along with the text, saying that states are successfully updated. For this, we need to update multiple control properties.

function OnCountryChange(id,controlData)

-- access the id of the control

IExtensionsLog.Log(id,"INFO")

-- access the selected value of the control

local controlValue = controlData['selectedvalue']

--populate the states of the selected country

local states = {}

states1[1] ='state1'

states1[2] ='state2'

states1[3] ='state3'

--create the property bag table to update each property with value along with controlid

local controlPropertyBag ={}

local dropdownControl2PropertyBag = {}

dropdownControl2PropertyBag['Data'] = states

dropdownControl2PropertyBag['Visible'] = true

controlPropertyBag['D2'] = dropdownControl2PropertyBag -- the key should be id of the control

local labelControlPropertyBag = {}

labelControlPropertyBag['Text'] = 'States are populated successfully'

labelControlPropertyBag['Visible'] = true;

controlPropertyBag['L1'] = labelControlPropertyBag

IExtensionsUI.SetData(controlPropertyBag) -- call back Extension UI to update the relevant properties

End

Accessing Control Values

Once the UI Task is completed the template returns the values of selected controls in Lua table. Lua table has the following properties:

  • Key: ID of the control.

  • Value: Selected value of the control.

For example, in a multiple control extension with country and state dropdown, following are the return values of the UI:

  • D1 = Country1

  • D2 = State1

Example: Return value of Multiple Control Extension

function Calculate(params)

local templateData = {}

templateData['Title'] = 'Multi Control Extension Title'

local countries ={}

countries[1] ='country1'

countries[2] ='country2'

countries[3] ='country3'

local controls ={}

local dropdownData1 = {}

dropdownData1['Title'] ='Country'

dropdownData1['PlaceHolder'] ='Select Country'

dropdownData1['Id'] ='D1'

dropdownData1['Data'] =countries

dropdownData1['ControlType'] ='DropDown'

local dropdownData2 = {}

local states = {}

states[1] ='state1'

states[2] ='state2'

states[3] ='state3'

dropdownData1['Title'] ='State'

dropdownData1['PlaceHolder'] ='Select State'

dropdownData1['Id'] ='D2'

dropdownData2['Data'] = states

controls[1] = dropdownData1

controls[2] = dropdownData2

templateData['Controls'] = controls

local controlvalues = IExtensionsUI.ShowUI('MPF_Multi_Control',templateData)

local conntrolValueString = ''

if(controlvalues == nil or controlvalues == '')

then

return conntrolValueString

end

for key,value in pairs(controlvalues) --

do conntrolValueString = conntrolValueString .. key .. value

end

IExtensionsLog.Log(conntrolValueString,"INFO")

return conntrolValueString

end

TitleResults for “How to create a CRG?”Also Available in