Question

Create virtual text column

Hi Creatio Community,

 

I want to create a virtual column in the case entity  with the normal section wizard and I'm a bit confused with the mutiple methods that have been posted in this forum. Does anyone have a custom code that works? :)

 

I want to create a virtual text 250 colum in the case section that automatically show the value of a text column of the case account.

 

Thanks a lot,

Markus

Like 0

Like

6 comments
Best reply

Markus Kumpfmüller,

 

here is a simple example I created and tested recently:

 define("CasePage", [], function() {
		return {
			entitySchemaName: "Case",
			attributes: {
				"CustomTextColumn": {
					dataValueType: this.Terrasoft.DataValueType.TEXT,
					type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
				},
				"Account": {
					"lookupListConfig": {
						"columns": ["UsrCustomAccountColumn"]
					},
					"dependencies": [
						{
							"columns": ["Account"],
							"methodName": "setCustomTextColumnValue"
						}
					]
				}
			},
			messages: {},
			methods: {
				onEntityInitialized: function() {
					this.callParent(arguments);
					this.setCustomTextColumnValue();
				},
 
				initOnRestored: function(callback, scope) {
					this.callParent(arguments);
					this.reloadEntity();
					this.setCustomTextColumnValue();
				},
 
				setCustomTextColumnValue: function() {
					var currentCaseAccount = this.get("Account");
					if (currentCaseAccount) {
						var currentCaseAccountCustomColumn = currentCaseAccount.UsrCustomAccountColumn;
						this.set("CustomTextColumn", currentCaseAccountCustomColumn);
					} else {
						this.set("CustomTextColumn", "");
					}
				}
			},
			details: /**SCHEMA_DETAILS*/ {} /**SCHEMA_DETAILS*/ ,
			diff: /**SCHEMA_DIFF*/ [
				{
					"operation": "insert",
					"name": "CustomAddedColumn",
					"values": {
						"layout": {
							"column": 0,
							"row": 10,
							"colSpan": 24,
							"rowSpan": 1
						},
						"bindTo": "CustomTextColumn",
						"caption": {
							"bindTo": "Resources.Strings.CustomAddedColumnCaption"
						},
					},
					"parentName": "ProfileContainer",
					"propertyName": "items"
				}
			] /**SCHEMA_DIFF*/
		};
	});

also the "CustomAddedColumnCaption" localizable string should be added to the CasePage schema. The logic is:

 

1) Populate the column when the page is opened (onEntityInitialized method)

2) In the "Account" attribute:

"lookupListConfig": {
						"columns": ["UsrCustomAccountColumn"]
					},

retrieve the value for the "UsrCustomAccountColumn" column from the "Account" object (added as a lookup to the CasePage)

3) In the "Account" attribute:

"dependencies": [
						{
							"columns": ["Account"],
							"methodName": "setCustomTextColumnValue"
						}
					]

modify the "CustomTextColumn" virtual column value each time account is changed in the "Account" lookup

4) Modify the value in the "CustomTextColumn" virtual column each time we open the account from the CasePage (click on the value in the "Account" lookup) and modify the value in the "UsrCustomAccountColumn" custom column on the account page and return back to the case page (initOnRestored method).

5) Also pay attention to this part in the diff:

"layout": {
							"column": 0,
							"row": 10,
							"colSpan": 24,
							"rowSpan": 1
						},

I took the last element that has "ProfileContainer" as a parent element, took its layout (which was:

{
						"operation": "merge",
						"name": "CaseOwner",
						"values": {
							"layout": {
								"column": 0,
								"row": 9,
								"colSpan": 24,
								"rowSpan": 1
							}
						}
					},

) and added 1 to the "row" attribute (to place my custom element right after the previous one).

 

The outcome is:

Hello Markus,

 

Please clarify the question a little:

 

1) Do you need it for the Freedom UI interface or 7x interface?

2) You need to place it in the case section page or on the edit page of the case section?

3) In case the answer to the question 2 is "case section" - which particular account use from the grid?

4) Which column of the case account should be displayed? Account name, account code, account primary contact?

Hi, thanks for replying,



I want to add the virutal column to 7x interface, int the case edit page to be precise.

The field of the account I want to be displayed is a field cretaed by me. It's a text field aswell

Markus Kumpfmüller,

 

here is a simple example I created and tested recently:

 define("CasePage", [], function() {
		return {
			entitySchemaName: "Case",
			attributes: {
				"CustomTextColumn": {
					dataValueType: this.Terrasoft.DataValueType.TEXT,
					type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
				},
				"Account": {
					"lookupListConfig": {
						"columns": ["UsrCustomAccountColumn"]
					},
					"dependencies": [
						{
							"columns": ["Account"],
							"methodName": "setCustomTextColumnValue"
						}
					]
				}
			},
			messages: {},
			methods: {
				onEntityInitialized: function() {
					this.callParent(arguments);
					this.setCustomTextColumnValue();
				},
 
				initOnRestored: function(callback, scope) {
					this.callParent(arguments);
					this.reloadEntity();
					this.setCustomTextColumnValue();
				},
 
				setCustomTextColumnValue: function() {
					var currentCaseAccount = this.get("Account");
					if (currentCaseAccount) {
						var currentCaseAccountCustomColumn = currentCaseAccount.UsrCustomAccountColumn;
						this.set("CustomTextColumn", currentCaseAccountCustomColumn);
					} else {
						this.set("CustomTextColumn", "");
					}
				}
			},
			details: /**SCHEMA_DETAILS*/ {} /**SCHEMA_DETAILS*/ ,
			diff: /**SCHEMA_DIFF*/ [
				{
					"operation": "insert",
					"name": "CustomAddedColumn",
					"values": {
						"layout": {
							"column": 0,
							"row": 10,
							"colSpan": 24,
							"rowSpan": 1
						},
						"bindTo": "CustomTextColumn",
						"caption": {
							"bindTo": "Resources.Strings.CustomAddedColumnCaption"
						},
					},
					"parentName": "ProfileContainer",
					"propertyName": "items"
				}
			] /**SCHEMA_DIFF*/
		};
	});

also the "CustomAddedColumnCaption" localizable string should be added to the CasePage schema. The logic is:

 

1) Populate the column when the page is opened (onEntityInitialized method)

2) In the "Account" attribute:

"lookupListConfig": {
						"columns": ["UsrCustomAccountColumn"]
					},

retrieve the value for the "UsrCustomAccountColumn" column from the "Account" object (added as a lookup to the CasePage)

3) In the "Account" attribute:

"dependencies": [
						{
							"columns": ["Account"],
							"methodName": "setCustomTextColumnValue"
						}
					]

modify the "CustomTextColumn" virtual column value each time account is changed in the "Account" lookup

4) Modify the value in the "CustomTextColumn" virtual column each time we open the account from the CasePage (click on the value in the "Account" lookup) and modify the value in the "UsrCustomAccountColumn" custom column on the account page and return back to the case page (initOnRestored method).

5) Also pay attention to this part in the diff:

"layout": {
							"column": 0,
							"row": 10,
							"colSpan": 24,
							"rowSpan": 1
						},

I took the last element that has "ProfileContainer" as a parent element, took its layout (which was:

{
						"operation": "merge",
						"name": "CaseOwner",
						"values": {
							"layout": {
								"column": 0,
								"row": 9,
								"colSpan": 24,
								"rowSpan": 1
							}
						}
					},

) and added 1 to the "row" attribute (to place my custom element right after the previous one).

 

The outcome is:

Oleg,

this helped me very much. Do you know how I could didplay this text as multiline? Currently the formatting of the source field in the account page is not being passed on.

 

Thanks,

Markus

Oleg Drobina writes:

Markus Kumpfmüller,

here is a simple example I created and tested recently:


 
 define("CasePage", [], function() {
		return {
			entitySchemaName: "Case",
			attributes: {
				"CustomTextColumn": {
					dataValueType: this.Terrasoft.DataValueType.TEXT,
					type: this.Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
				},
				"Account": {
					"lookupListConfig": {
						"columns": ["UsrCustomAccountColumn"]
					},
					"dependencies": [
						{
							"columns": ["Account"],
							"methodName": "setCustomTextColumnValue"
						}
					]
				}
			},
			messages: {},
			methods: {
				onEntityInitialized: function() {
					this.callParent(arguments);
					this.setCustomTextColumnValue();
				},
 
				initOnRestored: function(callback, scope) {
					this.callParent(arguments);
					this.reloadEntity();
					this.setCustomTextColumnValue();
				},
 
				setCustomTextColumnValue: function() {
					var currentCaseAccount = this.get("Account");
					if (currentCaseAccount) {
						var currentCaseAccountCustomColumn = currentCaseAccount.UsrCustomAccountColumn;
						this.set("CustomTextColumn", currentCaseAccountCustomColumn);
					} else {
						this.set("CustomTextColumn", "");
					}
				}
			},
			details: /**SCHEMA_DETAILS*/ {} /**SCHEMA_DETAILS*/ ,
			diff: /**SCHEMA_DIFF*/ [
				{
					"operation": "insert",
					"name": "CustomAddedColumn",
					"values": {
						"layout": {
							"column": 0,
							"row": 10,
							"colSpan": 24,
							"rowSpan": 1
						},
						"bindTo": "CustomTextColumn",
						"caption": {
							"bindTo": "Resources.Strings.CustomAddedColumnCaption"
						},
					},
					"parentName": "ProfileContainer",
					"propertyName": "items"
				}
			] /**SCHEMA_DIFF*/
		};
	});

also the "CustomAddedColumnCaption" localizable string should be added to the CasePage schema. The logic is:

1) Populate the column when the page is opened (onEntityInitialized method)

2) In the "Account" attribute:


 
"lookupListConfig": {
						"columns": ["UsrCustomAccountColumn"]
					},

retrieve the value for the "UsrCustomAccountColumn" column from the "Account" object (added as a lookup to the CasePage)

3) In the "Account" attribute:


 
"dependencies": [
						{
							"columns": ["Account"],
							"methodName": "setCustomTextColumnValue"
						}
					]

modify the "CustomTextColumn" virtual column value each time account is changed in the "Account" lookup

4) Modify the value in the "CustomTextColumn" virtual column each time we open the account from the CasePage (click on the value in the "Account" lookup) and modify the value in the "UsrCustomAccountColumn" custom column on the account page and return back to the case page (initOnRestored method).

5) Also pay attention to this part in the diff:


 
"layout": {
							"column": 0,
							"row": 10,
							"colSpan": 24,
							"rowSpan": 1
						},

I took the last element that has "ProfileContainer" as a parent element, took its layout (which was:


 
{
						"operation": "merge",
						"name": "CaseOwner",
						"values": {
							"layout": {
								"column": 0,
								"row": 9,
								"colSpan": 24,
								"rowSpan": 1
							}
						}
					},

) and added 1 to the "row" attribute (to place my custom element right after the previous one).

The outcome is:

Markus Kumpfmüller,

 

just add this line

"contentType": this.Terrasoft.ContentType.LONG_TEXT,

into the "values" object of the "CustomAddedColumn" element in diff:

{
					"operation": "insert",
					"name": "CustomAddedColumn",
					"values": {
						"contentType": this.Terrasoft.ContentType.LONG_TEXT,
						"layout": {
							"column": 0,
							"row": 10,
							"colSpan": 24,
							"rowSpan": 1
						},
						"bindTo": "CustomTextColumn",
						"caption": {
							"bindTo": "Resources.Strings.CustomAddedColumnCaption"
						},
					},
					"parentName": "ProfileContainer",
					"propertyName": "items"
				}

The column will become multiline after that.

Is there any example of how we can do the same in the Freedom UI?

 

Show all comments