Hello guys, I'm fairly new to Creatio, but I've seen there are a couple of functionalities that are missing. Some have never existed in Creatio and some others were in Classic but not available anymore. 

Right now I'm interested in calculated metrics, but for freedomUI. And maybe something similar for DataGrids

From what I see, It's seems possible for developers to make their own add-ons to provide certain functionalities and probably later put in on the marketplace.

 

I guess the normal procedure is reading the source code of the base packages of Creatio and seeing how you could edit them by importing/exporting/extending classes. Probably would help to downloa other marketplace freedomUI products and trying to see how did they do it

 

But well, I was wondering if someone that has had any experience in it maybe has some tips available before embarking into that journey

Like 1

Like

1 comments

Hello,

 

At this time, we don’t have a Calculated Metrics add-on that supports the Freedom UI. However, this functionality is on our development roadmap and is anticipated for release in versions 8.3-8.4, as it relies on advanced calculation features currently in progress for 8.2-8.3.

You can also take a look at the Custom Freedom UI page components article that provides instructions on developing your own components:

https://academy.creatio.com/docs/8.x/dev/development-on-creatio-platfor…

Show all comments


 

I have this list page, which has two QuickFilters, I need to get the values ​​from these quickfilters so that when the New button is pressed, these values ​​are passed to this new page to be taken into account when creating a new Payment.
One of the filters selects the contact and another selects the Loan to which the payment will be made. I have tried many ways, but I am unable to get the data from the quick filter.

Like 0

Like

5 comments
Best reply

How are you trying to do it? there is an element in the $context.attributes that must have the quickfilterName + "_value" and could be an array

How are you trying to do it? there is an element in the $context.attributes that must have the quickfilterName + "_value" and could be an array

Hi Jesus, I have tried to do it through that way but I only get undefined

hmm, if you do a console log to every change request in the handler (without specifying the attributeName) you can make sure you're using the correct name. I guess you've already done it, but just to make sure. 

 

Aditionally, there you could see in what format it comes. From what I see, it should show an array of objects, each object with an id and a displayValue

 

Probably the undefined is because of trying to get directly the value from the array without specifying which indexes. Or maybe you're trying to get the value from an inexistent field in the lookup. It's hard to tell without seeing the actual code

Carlos Soto,

Jesus is absolutely right. You may cover your task by taking the element code + "_value" in handler.

Please check one more time where exactly you are trying to take the filter value.

Hi Anhelina,

 

this is the code in the javascript of my form page

 

As you can see, the quickfilter does not have a control with which you can control the change in the field or recover the value that is set to it.

 

	"operation": "insert",
				"name": "QuickFilter_Loans",
				"values": {
					"layoutConfig": {
						"column": 1,
						"row": 1,
						"colSpan": 1,
						"rowSpan": 1
					},
					"type": "crt.QuickFilter",
					"config": {
						"caption": "#ResourceString(QuickFilter_Loans_config_caption)#",
						"hint": "",
						"icon": "filter-column-icon",
						"iconPosition": "left-icon",
						"defaultValue": [],
						"entitySchemaName": "DfcLoans",
						"recordsFilter": null
					}
Show all comments

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

Hi Community,

is it possible to custom image size ? not using template 'S, M, L, XL' in page No-Code editor, but more like custom value in form page client module or custom css?



 

I intend to increase the width of the image; the size would be the same as the field width.

Thanks

Like 2

Like

1 comments

Hi, yes its possible to add a CSS to a Creatio form page. 

Check this post:
https://community.creatio.com/questions/detail-styles-css

Show all comments

Hi Community.

Here example validator client side in Documentary

/* Declare the AMD module. */

define("UsrAppValidators_FormPage", /**SCHEMA_DEPS*/[]/**SCHEMA_DEPS*/, function/**SCHEMA_ARGS*/()/**SCHEMA_ARGS*/ {

    return {

        viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[

            {

                "operation": "insert",

                "name": "UsrName",

                "values": {

                    "layoutConfig": {

                        "column": 1,

                        "row": 1,

                        "colSpan": 1,

                        "rowSpan": 1

                    },

                    "type": "crt.Input",

                    "label": "$Resources.Strings.UsrName",

                    "control": "$UsrName"

                },

                "parentName": "LeftAreaProfileContainer",

                "propertyName": "items"

            }

        ]/**SCHEMA_VIEW_CONFIG_DIFF*/,

        viewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG*/{

            "attributes": {

                "UsrName": {

                    "modelConfigDiff": {

                        "path": "PDS.UsrName"

                    },

                    "validators": {

                        /* Bind the custom validator to the attribute. */

                        "MyValidator": {

                            "type": "usr.MyValidator",

                            "params": {

                                "invalidName": "test",

                                "message": "Invalid name"

                            }

                        }

                    }

                },

                "Id": {

                    "modelConfigDiff": {

                        "path": "PDS.Id"

                    }

                }

            }

        }/**SCHEMA_VIEW_MODEL_CONFIG*/,

        modelConfigDiff: /**SCHEMA_MODEL_CONFIG*/{

            "dataSources": {

                "PDS": {

                    "type": "crt.EntityDataSource",

                    "config": {

                        "entitySchemaName": "UsrAppValidators"

                    }

                }

            }

        }/**SCHEMA_MODEL_CONFIG*/,

        handlers: /**SCHEMA_HANDLERS*/[]/**SCHEMA_HANDLERS*/,

        converters: /**SCHEMA_CONVERTERS*/{}/**SCHEMA_CONVERTERS*/,

        validators: /**SCHEMA_VALIDATORS*/{

            /* The validator type must contain a vendor prefix.

            Format the validator type in PascalCase. */

            "usr.MyValidator": {

                "validator": function (config) {

                    return function (control) {

                        return control.value !== config.invalidName ? null: {

                            "usr.MyValidator": { message: config.message }

                        };

                    };

                },

                "params": [

                    {

                        "name": "invalidName"

                    },

                    {

                        "name": "message"

                    }

                ],

                "async": false

            }

        }/**SCHEMA_VALIDATORS*/

    };

});



is it possible to give argument of validator (invalidName) dynamic from other field value instead static like "invalidName": "test"? or can field value (other than control) accessed inside validator method?

Like 0

Like

5 comments

As far as I know, this is not possible at the moment to get a value of other attributes in a validator.

Alex Zaslavsky,

Thanks for your answer, really appreciate it.

I was told by support that it currently isn't possible, and their recommended workaround was to save the value to the JS global variable `window`, the example they gave was:

viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
"attributes": {                
    "DateTimeAttribute_lpcf566": {
        "modelConfig": {
            "path": "PDS.StartDate"
        },
        "change": {
            "request": "dw.StartDateChange",
        },
        "validators": {
            "StartDateIsNotNotLessThanProjectStartDate": {
                "type": "dw.StartDateIsNotNotLessThanProjectStartDate",
                "params": {
                    "message": "#ResourceString(StartDateIsNotNotLessThanProjectStartDateMessage)#",
                }
            }
        }
    },
}
},/**SCHEMA_VIEW_MODEL_CONFIG*/
handlers: /**SCHEMA_HANDLERS*/[
{
    request: "dw.StartDateChange",
    handler: async (request, next) => {
        /********/window.StartDate = await request.$context.DateTimeAttribute_lpcf566;/********/
        if(request.$context.IsStartDateInited) {
            request.$context.validate();
        }
        request.$context.IsStartDateInited = true;
        return next?.handle(request);
    }
}
],/**SCHEMA_HANDLERS*/
validators: /**SCHEMA_VALIDATORS*/{
"dw.StartDateIsNotNotLessThanProjectStartDate": {
    "validator": function (config) {
        return function (control) {
            return (!control.value || control.value >= /********/window.StartDate/********/)
                ? null
                : {"dw.StartDateValidator": {message: config.message}};
        };
    },
    "params": [
        {
            "name": "message"
        }
    ],
    "async": false
}
}/**SCHEMA_VALIDATORS*/

 

Where I've highlighted with surrounding comments the usage of the window to store this additional information to be used by the validator. Definitely not ideal, and hopefully they'll add this functionality in future, since async validators to perform some checks against the record when some field changes (and so where the validator will need the record's ID) seem to be the most useful usage of them, but this should at least work in the meantime.

M Khaerul Anwar,

 

Hi, Have you solved this and works?

 

I'm trying to implement on a similar situation using the provided code, but didn't understand from where is introduced/initialized IsStartDateInited  (request.$context.IsStartDateInited)?

 

Please could you help me?

 

Thanks

Julio Falcón

Julio.Falcon_Nodos,

No, I took a different approach from client-side to server-side validation instead.

Show all comments

Hey Community,

 

I have two details on my custom "Order" entity. Depends on order status i need to show/hide add button and the possibility to edit this details.

Is there any best practices for this scenario?



Thanks for help,

Oleksiis

Like 1

Like

6 comments
Best reply

Hello, 

Here is an example of how to hide the Add button in detail based on the condition:

define("UsrSchemaaae5d57eDetail", ["ConfigurationGrid", "ConfigurationGridGenerator",
	"ConfigurationGridUtilitiesV2"], function() {
	return {
		entitySchemaName: "UsrForHideTest",
		attributes: {
                -------------
			"IsAddEnabled": {
				dataValueType: Terrasoft.DataValueType.BOOLEAN,
				value: true
			}
		},
                -------------
		methods: {
                --------------
			init: function() {
				this.callParent(arguments);
				this.isAddEnabled();
			},
			isAddEnabled: function() {
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: "Contact"
                    });
                    esq.addColumn("Type");
                     esq.getEntity(this.values.MasterRecordId, function(result) {
                        if (result.success && result.entity.values.Type.displayValue == 'Customer') {
                            this.set("IsAddEnabled", false);
                        }
                    }, this);
			}
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "AddRecordButton",
				"values": {
					"visible": {"bindTo": "IsAddEnabled"}
				}
			},

Here we are hiding the button if the Type of the Contact = 'Customer'.

Regarding the editing of the detail, if I`m not mistaken, you cannot change it dynamically. 

Upd

I found the code snippet to hide Add button and added it to page - 

 

			isDetailEnabled: function(detailName) {
      		var productionStage = this.get("RdtStatus").displayValue;   
			if (detailName === "RdtSchemad16d4a3eDetail") {
			if(productionStage === "Planned"){
                    return true;       //Disable the "+" button
                }
                else{
                    return false;        //Enable the "+" button
                }
	}
			if (detailName === "RdtSchema670160a3Detail") {
			if(productionStage === "Planned"){
                    return true;       //Disable the "+" button
                }
                else{
                    return false;        //Enable the "+" button
                }
	}
			return this.callParent(arguments);
}

But now i have issue with clicking on data on editable grid



Hello,

not sure about best practices but for me isDetailEnabled also caused issues like that. I implemented this logic with replacing method in Detail code like this:

getAddRecordButtonEnabled: function() {
				var instance = this;
				var isEditable = instance.get("IsProductDetailEditable");
				return isEditable && this._isAddRecordButtonEnabled();
			},

adding attribute IsProductDetailEditable and settiging its value in onGridDataLoaded method override with an esq check of the parent page Status or any other condition you would need. This would cover add button, for the changes of existing rows you could add buisness rules for each field to block them for certain conditions, in my case implemented an esq check on save logic, with replacing method saveRowChanges from ConfigurationGridUtilities, check result would notify the user unability to save changes for that condition or proceed as normal.

Hello, 

Here is an example of how to hide the Add button in detail based on the condition:

define("UsrSchemaaae5d57eDetail", ["ConfigurationGrid", "ConfigurationGridGenerator",
	"ConfigurationGridUtilitiesV2"], function() {
	return {
		entitySchemaName: "UsrForHideTest",
		attributes: {
                -------------
			"IsAddEnabled": {
				dataValueType: Terrasoft.DataValueType.BOOLEAN,
				value: true
			}
		},
                -------------
		methods: {
                --------------
			init: function() {
				this.callParent(arguments);
				this.isAddEnabled();
			},
			isAddEnabled: function() {
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: "Contact"
                    });
                    esq.addColumn("Type");
                     esq.getEntity(this.values.MasterRecordId, function(result) {
                        if (result.success && result.entity.values.Type.displayValue == 'Customer') {
                            this.set("IsAddEnabled", false);
                        }
                    }, this);
			}
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "AddRecordButton",
				"values": {
					"visible": {"bindTo": "IsAddEnabled"}
				}
			},

Here we are hiding the button if the Type of the Contact = 'Customer'.

Regarding the editing of the detail, if I`m not mistaken, you cannot change it dynamically. 

Dmytro Vovchenko writes:

Hello, 

Here is an example of how to hide the Add button in detail based on the condition:


 
define("UsrSchemaaae5d57eDetail", ["ConfigurationGrid", "ConfigurationGridGenerator",
	"ConfigurationGridUtilitiesV2"], function() {
	return {
		entitySchemaName: "UsrForHideTest",
		attributes: {
                -------------
			"IsAddEnabled": {
				dataValueType: Terrasoft.DataValueType.BOOLEAN,
				value: true
			}
		},
                -------------
		methods: {
                --------------
			init: function() {
				this.callParent(arguments);
				this.isAddEnabled();
			},
			isAddEnabled: function() {
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: "Contact"
                    });
                    esq.addColumn("Type");
                     esq.getEntity(this.values.MasterRecordId, function(result) {
                        if (result.success && result.entity.values.Type.displayValue == 'Customer') {
                            this.set("IsAddEnabled", false);
                        }
                    }, this);
			}
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "AddRecordButton",
				"values": {
					"visible": {"bindTo": "IsAddEnabled"}
				}
			},

Here we are hiding the button if the Type of the Contact = 'Customer'.

Regarding the editing of the detail, if I`m not mistaken, you cannot change it dynamically. 

 

Thanks so much, will take a look on this.

Dmytro Vovchenko,

I tried your code-snippet for this implementation and seems the code not running with editable details. And code triggered only when opening the edit page of detail. 

So on the main page where details exists the Add button still visible :(

Show all comments

I have a lookup field on a detail (List of VAT options with an added column for the % values), im trying to use these now to calculate a value, how do I access the other column? I can access the VAT Code using this.get("UsrVatCode"), but want the associated column which as the % amount.

Like 1

Like

2 comments
Best reply
var lookupId = this.get("RecordColumn").value;
 
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "INSERTOBJECT"
});
 
esq.addColumn("Insert Object column you wish to view");
 
esq.getEntity(lookupId, function(result) {
    if (!result.success) {
        this.showInformationDialog("Error");
        return;
    }
    this.showInformationDialog(result.entity.values.Column You wish to view);
}, this);

This is the code that I used to get it working, if anyone needs it.

var lookupId = this.get("RecordColumn").value;
 
var esq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "INSERTOBJECT"
});
 
esq.addColumn("Insert Object column you wish to view");
 
esq.getEntity(lookupId, function(result) {
    if (!result.success) {
        this.showInformationDialog("Error");
        return;
    }
    this.showInformationDialog(result.entity.values.Column You wish to view);
}, this);

This is the code that I used to get it working, if anyone needs it.

There is also another approach: in the schema in the attributes property you can specify your column in the following manner:

"Your_column_from_the_page": {
					"dataValueType": this.Terrasoft.DataValueType.LOOKUP,
					"lookupListConfig": {
						"columns": ["column_name_from_the_lookup_object"]
					}
				},

As an example we can see that in the ContractPageV2 there is this attribute:

"Currency": {
					"dataValueType": this.Terrasoft.DataValueType.LOOKUP,
					"lookupListConfig": {
						"columns": ["Division"]
					}
				},

and we have access to the value of the "Division" column from the "Currency" lookup:

Show all comments

Hello Creatio community,

I am using Creatio base method:

/**
 * Opens edit page for selected record.
 * @protected
 */
editCurrentRecord: function() {
	const primaryColumnValue = this.getPrimaryColumnValue();
	// ** ESQ Method
	var object = this.GetObjData(primaryColumnValue);
	// existing implementation
	this.closeMiniPage();	
	if (primaryColumnValue) {
		this.editRecord(primaryColumnValue);
	}
},

Before page redirection I want to get all object data using ESQ filter ("GetObjData" method). The problem is that ESQ is asynchronous and the main method doesn't wait for "GetObjData" method to finish.

 

How can I convert "GetObjData" to synchronous so the main method "editCurrentRecord" awaits the child method?

 

Regards,

Lirzae

Like 0

Like

1 comments

Hello,

if you want to make your methods work in a defined order, you need to use the Terrasoft.chain logic. More about it in this article.

Show all comments

I'm trying too display the same object as 2 separate details filtered by a type, however I want to be able to make each detail auto set that type dependent on which detail was used to add the new record, ive been trying to find a solution but cant, any recomendations?

Like 1

Like

3 comments
Best reply

Hello Oliver,

To do this (set a different type value based on which detail is being used to add the record), you can set defaultValues in each of the details in the page code. See this article here: https://customerfx.com/article/passing-values-from-a-page-to-a-new-reco…

As far as filtering each detail by the specific type value, you can refer to this article: https://customerfx.com/article/filtering-a-detail-list-in-creatio-forme…

Ryan

Hello,

 

Please be informed that by the system's logic, the details still refer to the same object and even if you create several different details they are still based on the same object and therefore the edit pages will look the same. We already have this problem registered for our R&D department and in future releases this logic may be changed.

Mira Dmitruk,

 

I know they refer to the same object, are you not able to have the different details enter data slightly different? So if you enter it from one detail the type is set to "revenue" and the other "costs", otherwise id need to have a lookup to do it when it shouldn't be necessary.

Hello Oliver,

To do this (set a different type value based on which detail is being used to add the record), you can set defaultValues in each of the details in the page code. See this article here: https://customerfx.com/article/passing-values-from-a-page-to-a-new-reco…

As far as filtering each detail by the specific type value, you can refer to this article: https://customerfx.com/article/filtering-a-detail-list-in-creatio-forme…

Ryan

Show all comments

Hello community!

I need to set fields required based in values of a lookup at client side.

I was trying to test how isRequired works in attributes , but I found that the only way to work with it, is declaring the explicit value to True or False.

Tried to use a virtual column, and a method function, but it behaves weird.  

Here are my examples:

and this how it looks on screen:

 

It's showing the "Enter a Value" warning but they are supposed not to be required (* is missing).

 

Is there any way to workaround with this?

 

Thank you for your help.

Like 0

Like

3 comments
Best reply

Cesar Jaramillo,

Let's see what method of making fields required* dynamically actually works good – it is using rules/businessRules.

You can create a rule for your field, the condition can be any value of the page and its related lookups.

Like here:

But if you have to do this for several fields, it will take much time to set them for each field. 

And if there are many conditions or they are too complex, "businessRules" abilities can be not enough.

But we can set an attribute (boolean) to be a condition for each of these rules, like here:



The attribute value can be changed dynamically using "methods".

 

So here's what i'd advise you to do:



In my example the fields "Email" and "Preferred language" become required, if the contact Type is "Customer" and the "Owner" field is not empty.

1. Add an attribute of type BOOLEAN

attributes: {
	"FullInfoRequired": {
		"dataValueType": Terrasoft.DataValueType.BOOLEAN,
		"dependencies": [
			{
				"columns": ["Owner", "Type"],
				"methodName": "setFullInfoRequired"
			}
		]
	}
},

Each time any of the columns ("Owner" or "Type") is changed, the method "setFullInfoRequired" is called.

2. Add the method

setFullInfoRequired: function() {
	var type = this.get("Type");
	// ContactType.Client is a GUID for "Customer" type
	if (type.value === confConsts.ContactType.Client && this.get("Owner")) {
		this.set("FullInfoRequired", true);
	}
	else this.set("FullInfoRequired", false);
}

To set the attribute on page loading, immediately after the page loaded its data, you should also call this function in "onEntityInitialized":

onEntityInitialized: function() {
	this.callParent(arguments);
	this.setFullInfoRequired();
}

3. Add the rules using Page designer, as in my 2nd screenshot, for each field that should become required.

 

If the conditions are simple, just use businessRules as in the 1st screenshot.

 

Hello Cesar,

 

The isRequired attribute that uses the value that method returns works correctly in my local app (using bindTo: {"method name here"}). It seems that there is either some other custom logic related to these columns in the ContactPageV2 or maybe custom CSS that hides these * symbol. You need to look through all the logic related to these columns where you need to have the * symbol.

 

Best regards,

Oscar

Oscar Dylan,

Hi Oscar,  In my case, when the method returns True it works fine, but when it returns False, the * is gone, but the warning remains and it doesn't allow to save.  In what version did you try it?

Thanks!

Cesar Jaramillo,

Let's see what method of making fields required* dynamically actually works good – it is using rules/businessRules.

You can create a rule for your field, the condition can be any value of the page and its related lookups.

Like here:

But if you have to do this for several fields, it will take much time to set them for each field. 

And if there are many conditions or they are too complex, "businessRules" abilities can be not enough.

But we can set an attribute (boolean) to be a condition for each of these rules, like here:



The attribute value can be changed dynamically using "methods".

 

So here's what i'd advise you to do:



In my example the fields "Email" and "Preferred language" become required, if the contact Type is "Customer" and the "Owner" field is not empty.

1. Add an attribute of type BOOLEAN

attributes: {
	"FullInfoRequired": {
		"dataValueType": Terrasoft.DataValueType.BOOLEAN,
		"dependencies": [
			{
				"columns": ["Owner", "Type"],
				"methodName": "setFullInfoRequired"
			}
		]
	}
},

Each time any of the columns ("Owner" or "Type") is changed, the method "setFullInfoRequired" is called.

2. Add the method

setFullInfoRequired: function() {
	var type = this.get("Type");
	// ContactType.Client is a GUID for "Customer" type
	if (type.value === confConsts.ContactType.Client && this.get("Owner")) {
		this.set("FullInfoRequired", true);
	}
	else this.set("FullInfoRequired", false);
}

To set the attribute on page loading, immediately after the page loaded its data, you should also call this function in "onEntityInitialized":

onEntityInitialized: function() {
	this.callParent(arguments);
	this.setFullInfoRequired();
}

3. Add the rules using Page designer, as in my 2nd screenshot, for each field that should become required.

 

If the conditions are simple, just use businessRules as in the 1st screenshot.

 

Show all comments