Multiple control extensions
- Last UpdatedFeb 17, 2025
- 5 minute read
IExtensionsUI supports rendering of multiple controls in the same view.
Method
-
IExtensionsUI.ShowUI(TemplateName,TemplateData)
Parameters
-
TemplateName: MPF_Multi_Control
-
TemplateData: Contains metadata of the controls. It has the following properties:
-
Title: Title for the custom function
-
Control: Collection of UI controls. It contains meta data for each UI control.
Following are the standard properties of a control:-
Title: Title of the control.
-
Id: Unique ID of the control. For example, D1.
-
ControlType: Type of control. For example, dropdown.
-
Visible: Boolean property. Defines the visibility state of the control. By default, the control is visible.
-
Disable: Boolean property. Defines the enabled or disabled state of the control. By default, the control is enabled.
-
-
Supported Controls
The following controls are supported as multiple control extensions:
-
Dropdown
-
Label
-
Text Area
-
Button
-
Asset Browser
Apart from the standard properties, each control contain the following specific properties:
Dropdown
This control is used to display drop-down list. Following properties are available for dropdown control:
-
Placeholder: Placeholder text of the control.
-
Data: Data to list in the control.
Example
local templateData = {}
templateData['Title'] = 'Multi Control Extension Title'
local data = {}
countries[1] ='Country1'
countries[2] ='Country2'
countries[3] ='Country3'
local dropdownData2 = {}
dropdownData2['Id'] ='D2' --
dropdownData2['ControlType'] ='DropDown'
dropdownData2['Visible'] =false
dropdownData2['Title'] ='Dropdown Title'
dropdownData2['PlaceHolder'] ='Select Value'
dropdownData2['Data'] = data
local controls ={}
controls[1] = dropdownData2
templateData['Controls'] = controls
IExtensionsUI.ShowUI('MPF_Multi_Control',templateData)
Return Value
This control returns the key of the selected item.
Label
This control is used to display messages. For example, error and warning. Following properties are available for Label control:
-
Text: Display text for the label control.
-
Type: Type of message. Following are the supported message types:
-
Error: Displays error message in red.
-
Warning: Displays warning message with warning icon.
-
Success: Displays success message with warning icon.
-
HTML: Displays HTML encoded text.
-
Example
local templateData = {}
templateData['Title'] = 'Multi Control Extension Title'
local labelControl = {}
labelControl['Text'] = 'The Selected Node does not contain any Assets'
labelControl['Type'] = 'Error'
labelControl['Visible'] = true
labelControl['ControlType'] = 'Label'
labelControl['Id'] = 'L1'
templateData['Controls'] = controls
IExtensionsUI.ShowUI('MPF_Multi_Control',templateData)
Return Value
This control returns an empty string.
Note: Text for the label control can have up to a maximum of 50 characters, for better viewing across all viewports.
Text Area
This control is used to display user defined text.
-
Placeholder: Placeholder text of the control.
-
MaxLength: Maximum character length of the control.
-
DefaultValue: Default text of the control.
Example
local textAreaControl2 = {}
textAreaControl2['Id'] ='T2'
textAreaControl2['Visible'] = true
textAreaControl2['Title'] = 'Asset Details'
textAreaControl2['Placeholder'] = 'Details'
textAreaControl2['MaxLength'] = 100
textAreaControl2['ControlType'] = 'TextArea'
textAreaControl2['DefaultValue'] = ‘Selected Asset'
Note:
- When updating the task, the text area value should be a maximum of 100 characters.
- Set the Visible property to True to make sure the control is displayed in the view.
Button
This control maps a button to the data of a control.
-
Text: Display text of the control.
-
MappedControlIds: Data can be retrieved from the required controls using the mapped control property. In the below example Dropdown with ID D1 is mapped to a button, on clicking the value from dropdown is retrieved.
Example
local buttonControl1 = {}
buttonControl1['Id'] ='B1'
buttonControl1['Text'] = 'Click me to get Asset Details'buttonControl1['MappedControlIds'] = 'D1’
buttonControl1['ControlType'] = 'Button'
buttonControl1['events'] = onclickeventObject
Onclick Event
The onclick event accepts the name of the lua function to call when the button is clicked.
It retrieves and stores the data in a property bag, and updates it to the required control.
Example
The following example shows two drop down lists with IDs D1 and D2, mapped to a button control.
On clicking the button, the values get updated to the text area with the ID T2.
function OnClick(Id,controlData)
local dropdown1value =controlData['D1']
local dropdown2value ='controlData['D2']
local controlPropertyBag ={}
local textAreaPropertyBag ={}
textAreaPropertyBag['SelectedValue']= 'Temprature'
controlPropertyBag['T2'] = textAreaPropertyBag
IExtensionsUI.SetData(controlPropertyBag)
end
The lua function specified in the event accepts the following parameters:
-
id: ID of the control that raised the event.
-
controlData: Lua table containing data of the mapped control ID.
Example:
The following example shows two drop down lists with IDs D1 and D2, mapped to a button control.
On clicking the button, the values from the two dropdown are retrieved, added, and updated to the text area, using the onclick event.
local onclickeventObject ={}
onclickeventObject['onclick'] = 'OnClick'
Events
Events is a special property available for all controls. It requires the name of the lua function to call.
The following events are supported:
-
onchange: Accepts the name of the lua function to call.
Example: onchange
local eventsObject = {}
eventsObject['onchange'] = 'OnCountryChange'
local countryDropdown ={}
countryDropdown[‘onchange’] = eventsObject
The following properties can be updated in an event:
-
General Properties
-
Visible
-
Disable
-
-
Drop-down
-
Data
-
DefaultValue
-
-
Label
-
Text
-
The lua function specified in the event accepts the following parameters:
-
id: ID of the control.
-
controlData: Lua table containing data of the control which raised the event. controldData has below properties:
-
selectedValue : selected value of the control which raised the event
Note:
- All properties are case sensitive.
- IDs of the controls should be unique.
- Controls will render in the order specified in the lua table.
Asset Browser
This control integrates the asset browser control to the custom function. It helps select an asset from the list of Assets.
Properties
-
NameToDisplay: Displays the name of the asset.
-
AssetDescription: Displays the description of the asset.
-
AllowWordOrder: Displays whether Work Orders are allowed or not.
Example
assetBrowser1['Id'] = 'A1'
assetBrowser1['Title'] = 'Asset'
assetBrowser1['ControlType'] = 'AssetBrowser'
assetBrowser1['Placeholder'] = 'Select Asset'
Return Value
This control returns the asset information object. The asset information object contains the following list of properties:
-
Asset
-
DisplayName
-
AssetActualName
-
AssetDescription
-
AssetTypeId
-
Id
-
ParentId
-
NameToDisplay
-
AllowWorkOrder
-
TypeOfAsset
Note: Use the NameToDisplay property to display the name of the asset.
Example: The below example shows how to access the asset information:
local listReturn = IExtensionsUI.ShowUI('MPF_Multi_Control',templateData)
local assetBrowserControl1Value = listReturn['A1']
IExtensionsLog.Log('value of AssetDescription ' .. assetBrowserControl1Value['AssetDescription'],"Debug" )
The Asset property contains the following properties:
-
AllowWorkOrder
-
ApplicationID
-
AssetActualName
-
AssetDescription
-
AssetTypeId
-
ChildCount
-
DisplayName
-
Epc
-
ExtendedProperties
-
FromExternal
-
Id
-
IsDeleted
-
ItemOrder
-
NameForSorting
-
NameToDisplay
-
ParentId
-
TypeOfAsset
Example
function Initialize()
IExtensionsLog.Log("start of Init method","Debug")
IExtensionsSettings.NumberOfParameters = 0
IExtensionsSettings.DisplayName = "@StringOutPut"
IExtensionsSettings.SetReturnType("String")
IExtensionsLog.Log("End of Init method","Debug")
IExtensionsLog.Log("Before calc","Debug")
end
function Calculate(params)
IExtensionsLog.Log("Start of Calc","Debug")
templateData = {}
templateData['Title'] = 'Multi Control Extension Title'
local controls ={}
local assetBrowser1 = {}
assetBrowser1['Id'] = 'A1'
assetBrowser1['Title'] = ‘ Asset'
assetBrowser1['ControlType'] = 'AssetBrowser'
assetBrowser1['Placeholder'] = 'Select Asset ‘
controls[1] = assetBrowser1
templateData['Controls'] = controls
local listReturn = IExtensionsUI.ShowUI('MPF_Multi_Control',templateData)
local assetBrowserControl1Value = listReturn['A1']
local assetDetails = assetBrowserControl1Value['Asset']
IExtensionsLog.Log('value of Name to display ' .. assetBrowserControl1Value['NameToDisplay'],"Debug" ) -- Asset info property
IExtensionsLog.Log('value of AssetDescription ' .. assetBrowserControl1Value['AssetDescription'],"Debug" )-- Asset info property
IExtensionsLog.Log('value of AllowWorkOrder ' .. tostring(assetBrowserControl1Value['AllowWorkOrder']),"Debug" )-- Asset info property
IExtensionsLog.Log('value of nested level childcount is ' .. assetDetails['ChildCount'],"Debug" )-- Asset property
IExtensionsLog.Log('value of nested level EPC is ' .. assetDetails['Epc'],"Debug" )-- Asset property
local assetName = assetBrowserControl1Value['NameToDisplay']
return assetName
end