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 0

Like

2 comments
Best reply

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

Ryan Farley,

 

Thanks. it worked.

Show all comments

Hello!

 

I have these 3 buttons that I want to hide or remove on a condition.

 

This is the code that removes them. 

 

If the Ownership Status (added in the attributes) is 'Inactive', then these buttons should dissapear.

 

Does anybody know how I can do this on a condition in diff?

Like 0

Like

2 comments
Best reply

First of all, rather than using operation: remove, change that to operation: merge, which will let you modify the properties of the element. Then, you'll bind the visible property of them to an attribute. To show or hide them, you'll set the attribute to true or false. See this article here for more details: https://customerfx.com/article/how-to-enable-or-disable-a-field-on-a-pa…

Also, to set the attribute to true or false, you'll either need to add that to a change event for whatever fields use the conditions or when the page opens, using the onEntityInitialized function. To base it on the selection of fields, you can wire a change event as shown here: https://customerfx.com/article/triggering-an-event-when-a-field-is-chan…

Info on the onEntityInitialized function and other basic info on working with page code here: https://customerfx.com/article/getting-started-with-writing-code-for-bp…

Hope this helps get you started.

Ryan

First of all, rather than using operation: remove, change that to operation: merge, which will let you modify the properties of the element. Then, you'll bind the visible property of them to an attribute. To show or hide them, you'll set the attribute to true or false. See this article here for more details: https://customerfx.com/article/how-to-enable-or-disable-a-field-on-a-pa…

Also, to set the attribute to true or false, you'll either need to add that to a change event for whatever fields use the conditions or when the page opens, using the onEntityInitialized function. To base it on the selection of fields, you can wire a change event as shown here: https://customerfx.com/article/triggering-an-event-when-a-field-is-chan…

Info on the onEntityInitialized function and other basic info on working with page code here: https://customerfx.com/article/getting-started-with-writing-code-for-bp…

Hope this helps get you started.

Ryan

Show all comments

Hello team,

 

I was trying to replicate account photo functionality in a custom section. I noticed that the getAccountLogo method gets called twice. Please see below screenshot (Hello from getAccountLogo is repeated twice)



This is causing errors in my functionality. Can someone please check?

Like 0

Like

1 comments

Hi,

If you want to add a photo to your custom section then there is instruction on how to do it.

Take a look at this conversation, there you can find an article and example.

Show all comments

Hi community,

 

I try to display (or not) an element based on information found on the contact page of the connected user. I tried with a business rule but I only can choose the user connected and not its related objects and their attributes.

 

So I tried something like that in the methods :

		methods: {
			init: function() {
				this.callParent(arguments);
				this.mixins.MultiChoiceMixin.init.call(this, arguments);
				// console.log(this.checkIfInHR());
				},
			/** 
			* Check if connected user is in HR department
			* @param  {string} departmentId  The contact's department Id
			* @param  {string} contactTypeId The contact's type Id
			* @return {bool} 			true if user is in HR department, otherwise false
			*/
			checkIfInHR: function(departmentId = "", contactTypeId = ""){
 
				// if called without args, query connected contact
				if (departmentId == "" && contactTypeId == ""){
					var esq = Ext.create("Terrasoft.EntitySchemaQuery", {rootSchemaName: "Contact"});
 
					// query the contact's department and contact's type
					esq.addColumn("Department");
					esq.addColumn("Type");
 
					// Execute the query 
					esq.getEntity(Terrasoft.SysValue.CURRENT_USER_CONTACT.value, function(res) {
						if (res.success){
							// call checkIfHR again but with args this time
							this.checkIfHR(res.entity.values.Department.value, res.entity.values.Type.value);
						}}, this);
				} else {
					// if args are passed
					// console.log() will be removed in prod
					console.log("departmentId : ", departmentId);
					console.log("contactTypeId : ", contactTypeId);
					console.log("response : ", departmentId == "ca611978-6277-4576-8a96-22ae54fe4d79" && contactTypeId == "60733efc-f36b-1410-a883-16d83cab0980");
					// 1st Id : HR department, 2nd Id: Our company
					return departmentId == "ca611978-6277-4576-8a96-22ae54fe4d79" && contactTypeId == "60733efc-f36b-1410-a883-16d83cab0980";
				}
			}
		}

Then I tried to call this method in the DIFF part :

			{
				"operation": "insert",
				"name": "Tab0f271a37TabLabel",
				"values": {
					"caption": {
						"bindTo": "Resources.Strings.Tab0f271a37TabLabelTabCaption"
					},
					"items": [],
					"order": 11
				},
				"parentName": "Tabs",
				"propertyName": "tabs",
				"index": 10,
				"enabled": this.checkIfInHR()
			},

but it always gives me this error now:

Uncaught TypeError: this.checkIfInHR is not a function

 

Do you have a better way to hide a tab based on values in the user connected' contact page or a way to fix my error ?

 

Best regards,

 

Julien G.

Like 0

Like

3 comments
Best reply

Hi Julien,

 

I cannot see the checkIfInHR method call on the init method execution, but I suppose you wanted to call it inside the "enabled" property of the Tab0f271a37TabLabel object. Ok, but the problem is that you need to use:

"enabled": {"bindTo": "checkIfInHR"},

and also the "enabled" property should be initialized inside the "values" object. So the code should've been:

onEntityInitialized: function() {
				this.callParent(arguments);
				this.mixins.MultiChoiceMixin.init.call(this, arguments);
				this.checkIfInHR();
				},
 
....
 
{
				"operation": "insert",
				"name": "Tab0f271a37TabLabel",
				"values": {
					"enabled": {"bindTo": "checkIfInHR"},
					"caption": {
						"bindTo": "Resources.Strings.Tab0f271a37TabLabelTabCaption"
					},
					"items": [],
					"order": 11
				},
				"parentName": "Tabs",
				"propertyName": "tabs",
				"index": 10
			},

The next problem is that this approach won't work since there is no "enabled" property for tab labels. So the general approach should be modified.

 

I would suggest using this check in the onEntityInitialized method:

onEntityInitialized: function() {
				this.callParent(arguments);
				this.mixins.MultiChoiceMixin.init.call(this, arguments);
				this.reformTabsCollection();
			},
			reformTabsCollection: function(){
				this.checkIfInHR();
				var tabsCollection = this.get("TabsCollection");
				if (this.get("BooleanAttribute")==false) {
                        tabsCollection.removeByKey("TheTabYouNeedToBeNotVisible");
                    }
			}

Also you need to create some bool attribute where the result of the checkIfInHR method will be written (using this.set("BooleanAttribute", true) or this.set("BooleanAttribute", false) at the end of the checkIfInHR method execution based on the checkIfInHR method results). There is no need to store the tab on the page in case it should be non clickable.

 

Best regards,

Oscar

Change it from this:

"enabled": this.checkIfInHR()

To this (and move inside of "values"):

"enabled": { "bindTo": "checkIfInHR" }

Ryan

Hi Julien,

 

I cannot see the checkIfInHR method call on the init method execution, but I suppose you wanted to call it inside the "enabled" property of the Tab0f271a37TabLabel object. Ok, but the problem is that you need to use:

"enabled": {"bindTo": "checkIfInHR"},

and also the "enabled" property should be initialized inside the "values" object. So the code should've been:

onEntityInitialized: function() {
				this.callParent(arguments);
				this.mixins.MultiChoiceMixin.init.call(this, arguments);
				this.checkIfInHR();
				},
 
....
 
{
				"operation": "insert",
				"name": "Tab0f271a37TabLabel",
				"values": {
					"enabled": {"bindTo": "checkIfInHR"},
					"caption": {
						"bindTo": "Resources.Strings.Tab0f271a37TabLabelTabCaption"
					},
					"items": [],
					"order": 11
				},
				"parentName": "Tabs",
				"propertyName": "tabs",
				"index": 10
			},

The next problem is that this approach won't work since there is no "enabled" property for tab labels. So the general approach should be modified.

 

I would suggest using this check in the onEntityInitialized method:

onEntityInitialized: function() {
				this.callParent(arguments);
				this.mixins.MultiChoiceMixin.init.call(this, arguments);
				this.reformTabsCollection();
			},
			reformTabsCollection: function(){
				this.checkIfInHR();
				var tabsCollection = this.get("TabsCollection");
				if (this.get("BooleanAttribute")==false) {
                        tabsCollection.removeByKey("TheTabYouNeedToBeNotVisible");
                    }
			}

Also you need to create some bool attribute where the result of the checkIfInHR method will be written (using this.set("BooleanAttribute", true) or this.set("BooleanAttribute", false) at the end of the checkIfInHR method execution based on the checkIfInHR method results). There is no need to store the tab on the page in case it should be non clickable.

 

Best regards,

Oscar

Oscar Dylan,

 Thank you very much !

 

Best regards,

 

Julien

Show all comments



Dear Community,



I was wondering if there's a comprehensive list somewhere where we can find all the attributes for the schema page.

Some of the examples are:

- In diff we can add different things like

"operation": "delete",

                    "name": "",

                    "propertyName": "",

                    "parentName": "",

                    "values": {}

Where can I find a list of things I can put in the Diff and "values"?

Same thing for messages, attributes, ...



Thank you in advance!

Like 0

Like

3 comments

Hi Yosef,

 

You can find the chain of articles here that describes multiple schema configurations:

https://academy.creatio.com/documents/technic-sdk/7-16/introduction-3

The diff array article among others describes the possbile operations that you refer to

https://academy.creatio.com/documents/technic-sdk/7-16/diff-array

 

Regards,

Dean

dean parrett,



Thank you for the quick response but this isn't exactly what I'm looking for, it sure is a great start for beginners!



What I'm looking for is like an "extended" list. If I want to enable or disable an item, I would be adding the ' "enable": true ' to the diff. This is nowhere to be found on the second link.



While programming I found bits and pieces of information of these properties in different posts, but I'm looking for something more complete in one place.



If anyone knows or has made a list like this, please let me know!

Thank you

Show all comments