Question

Syntax that read the column value from console page

Hi Community,

I have a requirement that an error message will populate once you save a record in details section with a record no which is already exists. The error message format is like "Settlement ID is already exists with record no 1001(where 1001 is the record no of parent record)".

Here is the code below that I have written.

define("AMDSchema09eec6a7Page", [], function() {
	return {
		entitySchemaName: "AMDSettlement",
		attributes: {},
		modules: /**SCHEMA_MODULES*/{}/**SCHEMA_MODULES*/,
		details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
		businessRules: /**SCHEMA_BUSINESS_RULES*/{}/**SCHEMA_BUSINESS_RULES*/,
		methods: {
			/*setValidationConfig: function() {
                // This calls the initialization of validators for the parent view model.
                this.callParent(arguments);
                this.addColumnValidator("AMDSettlementID", this.SettlementIDDuplicateValidator);
            },*/
			save: function(){
				var currentvalue = this.get("AMDSettlementID");
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "AMDSettlement" });
				esq.addColumn("AMDSettlementID");
				esq.addColumn("AMDClaims");
				esq.filters.add("AMDSettlementID", Terrasoft.createColumnFilterWithParameter(
  					Terrasoft.ComparisonType.EQUAL, "AMDSettlementID", currentvalue));
				esq.getEntityCollection(function(response) {
  					if (response && response.success) {
						console.log("Test ",response);
   						var result = response.collection.collection.length;
						if (result > 0)
							{Terrasoft.showErrorMessage("Settlement ID {result} already Exists");
							return false;}
						else{
							return true;}
						}
 					}, this);
				}
			},

So I need a syntax in "Terrasoft.showErrorMessage()" which will read the column value from the console page(read from rowConfig) . Below adding the picture of console page.

 

 

Best Regards,

Jagan

 

 

 

Like 0

Like

3 comments

Hi Jagan,

 

In your part of code:

Terrasoft.showErrorMessage("Settlement ID {result} already Exists")

you need to pass something to this {result} in the following manner (standard JavaScript):

Terrasoft.showErrorMessage(`Settlement ID ${result} already Exists`)

and the result should be formed according to your business task. If you need to understand what to pass to the result - debug the code, set the breakpoint before showing this error message and in the console itself check what is passed and how to get to the values needed. You will be able to find out what should be passed in the console directly.

 

Best regards,

Oscar

Hi.

 

In addition to the Oscar comment please as well read this post regarding async validation i think You would like to achieve:

 

https://community.creatio.com/questions/overriding-save-function

 

Best regards,

Marcin

Oscar Dylan,

Hi Oscar,

In the above code the error message is coming when you create a record with existing record no but if you create a record with different record no it is not getting saved. Could anyone help me what is wrong with the code.

 

Regards,

Jagan

Show all comments