How to set the value in a text attribute based on another lookup type attribute in Classic UI
Hi Team,
Could anyone please help me achieving the things below?
I have added two custom attributes in the client module.
One of lookup type and the other for text. As soon as the user selects the value in the Title Dropdown, the Description text field should be auto-populated with the corresponding value of description being fetched from a data source of Title.
The source lookup is as follows:
attributes: {
"UsrTitle": {
dataValueType: Terrasoft.DataValueType.LOOKUP,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
isSimpleLookup: true,
referenceSchemaName: "UsrTitle",
isRequired: true,
},
"UsrDescription": {
dataValueType: Terrasoft.DataValueType.MAXSIZE_TEXT,
type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
value: ""
}
}
diff: [
{
"operation": "insert",
"name": "MyMenu",
"propertyName": "items",
"values": {
"generateId": false,
"itemType": Terrasoft.ViewItemType.CONTAINER,
"items": []
}
},
{
"operation": "insert",
"parentName": "MyMenu", // The container where the input box will be added
"propertyName": "items",
"name": "UsrTitle",
"values": {
"bindTo": "UsrTitle",
"labelConfig": {
"caption": "Title"
},
},
"bindTo": "UsrTitle",
"enabled": true,
"contentType": 3
},
{
"operation": "insert",
"parentName": "MyMenu",
"propertyName": "items",
"name": "UsrDescription",
"values": {
"bindTo": "UsrDescription",
"labelConfig": {
"caption": "Description"
},
"contentType": 0,
"layout": {
"column": 4,
"row": 5,
"colSpan": 20,
"rowSpan": 4
},
"controlConfig": {
"placeholder": "Enter your text here"
},
"classes": {
"wrapClassName": ["custom-input-box-class"]
}
}
},
{
"operation": "insert",
"parentName": "MyMenu",
"propertyName": "items",
"name": "MainContactButton",
"values": {
"itemType": Terrasoft.ViewItemType.BUTTON,
"caption":"Create Ticket",
"enabled": true
}
},
]
Please note that this is a custom client module which does not belong to a section, hence not able to achieve this using the OOTB business rules. Kindly help!
Thanks,
Sarika
Like
First of all, you'll need to have a change event for when the lookup attribute it selected, add something like this to the lookuip attribute:
"UsrTitle": { dataValueType: Terrasoft.DataValueType.LOOKUP, type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN, isSimpleLookup: true, referenceSchemaName: "UsrTitle", isRequired: true, onChange: "getTitleDescription" }
Then, add the getTitleDescription method to the methods. When a value is selected this will get called and you can go retrieve the description via an EntitySchemaQuery to set in the other attribute:
getTitleDescription: function() { var title = this.get("UsrTitle"); // now do an esq to get the description using title.value and then set in the description attribute }
You could try adding the Description to the lookup attribute's lookupListConfig to avoid the esq, but I am not sure if that works for a virtual lookup attribute. However, doing an esq there would work fine.
Ryan
First of all, you'll need to have a change event for when the lookup attribute it selected, add something like this to the lookuip attribute:
"UsrTitle": { dataValueType: Terrasoft.DataValueType.LOOKUP, type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN, isSimpleLookup: true, referenceSchemaName: "UsrTitle", isRequired: true, onChange: "getTitleDescription" }
Then, add the getTitleDescription method to the methods. When a value is selected this will get called and you can go retrieve the description via an EntitySchemaQuery to set in the other attribute:
getTitleDescription: function() { var title = this.get("UsrTitle"); // now do an esq to get the description using title.value and then set in the description attribute }
You could try adding the Description to the lookup attribute's lookupListConfig to avoid the esq, but I am not sure if that works for a virtual lookup attribute. However, doing an esq there would work fine.
Ryan