How to modify a validation message set thru the object permission with the custom one?

I want to replace the usual message

"You do not have permission to add an entry in the "<>" table"

 with,

"You do not have permission to add a file in this tab"

Like 0

Like

1 comments

It's not possible since this message is returned by the GetCanEdit method from RightsService class from this part of code:

 

if (isNew) {
				bool canAppend = (rightLevels &amp; SchemaOperationRightLevels.CanAppend) == SchemaOperationRightLevels.CanAppend;
				return rightsHelper.GetCanAppendSchemaOperationRight(schemaName)
					? string.Empty
					: (canAppend
						? string.Format(new LocalizableString("Terrasoft.Core", "Entity.Exception.NoRightFor.Insert"), schema.Caption.Value)
						: string.Format(new LocalizableString("Terrasoft.Core", "LicHelper.Exception.LicenceNotFound")));
			}

And the string is formed using the core entity exception.

Show all comments

Hi,

I am wanting to achieve the following:

1. Activity Status = Completed AND Category = To Do

2. Upon save, field validation occurs to display a pop-up (or similar) asking user to set a correct Category value

 

This is to improve data analytics for the category data, as currently my users are not changing this value when an activity is completed. A category of To Do, does not make sense if the activity is now complete you see.

I found this post - https://community.creatio.com/questions/messagebox-display-popup-box-requesting-user-confirm-some-situation, but I do not know how to complete this for the correct actions i.e. Only when the above condition is in place and click Yes means continue and submit the form or No means close window and allow user to change Category value.

Thanks for any help.

 

Like 0

Like

2 comments
Best reply

Hello Mark, 



Please refer to the following code in order to add the functionality requested:

 

define("ActivityPageV2", [], function() {
    return {
        entitySchemaName: "Activity",
        messages: {
        },
        methods: {
            save: function() {
                var IsToDoCategory = this.get("ActivityCategory") &amp;&amp; 
                    this.get("ActivityCategory").value === "f51c4643-58e6-df11-971b-001d60e938c6";
                var IsCompletedStatus = this.get("Status") &amp;&amp; 
                    this.get("Status").value === "4bdbb88f-58e6-df11-971b-001d60e938c6";
                if (IsCompletedStatus &amp;&amp; IsToDoCategory) {
                    this.showConfirmationDialog("Please, set proper category!");
                } else {
                    this.callParent(arguments);
                }
            }
        },
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
    };



Kind regards,

Roman

Hello Mark, 



Please refer to the following code in order to add the functionality requested:

 

define("ActivityPageV2", [], function() {
    return {
        entitySchemaName: "Activity",
        messages: {
        },
        methods: {
            save: function() {
                var IsToDoCategory = this.get("ActivityCategory") &amp;&amp; 
                    this.get("ActivityCategory").value === "f51c4643-58e6-df11-971b-001d60e938c6";
                var IsCompletedStatus = this.get("Status") &amp;&amp; 
                    this.get("Status").value === "4bdbb88f-58e6-df11-971b-001d60e938c6";
                if (IsCompletedStatus &amp;&amp; IsToDoCategory) {
                    this.showConfirmationDialog("Please, set proper category!");
                } else {
                    this.callParent(arguments);
                }
            }
        },
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
        diff: /**SCHEMA_DIFF*/[]/**SCHEMA_DIFF*/
    };



Kind regards,

Roman

Thanks for your reply Roman, this worked beautifully.

 

I am interested in the GUID values you have in the code, is there any meaning to these values?

 

Note for others, the code above needs the &amp;&amp; replaced with &&

Show all comments

Hello Community,

 

I have a use case where when a user uploads a contact profile photo, I need to perform specific validations - Eg Check the bit depth & file format of the image. If the bit depth or the format doesn't match, I need to reject the image and show a message to the user. These validations are complicated and sometimes not possible on the client side using JS. 

 

I am aware that Contact profile photo gets uploaded via the out-of-the-box ImageAPIService. How do I customize or extend the service to add my own validations on the server side?

Like 0

Like

1 comments

Hello Shrikanth, 

 

Unfortunately, we do not have the exact example of your business task realization. However, we recommend that you take a look at the following Community post where a similar task and ways of its implementation are described: https://community.creatio.com/questions/attachement

 

Please, let us know in case any further information is required. 

 

Best regards, 

Olga. 

Show all comments

I am trying to implement validation logic in client module edit page of a section.

I want to save the column value of UsrAttributeName (a lookup) into a variable.

To do this, I am using this.get("UsrAttributeName").displayValue. But when Page is loaded it hangs and console shows the error 

message: Uncaught TypeError: Cannot read property 'displayValue' of undefined 

Like 0

Like

2 comments

Hello! 

 

1. To add validation use this.addColumnValidator method in setValidationConfig method.

Please, find the example in the Academy article: https://academy.creatio.com/documents/technic-sdk/7-16/how-add-field-va…

 

2. If the column value is not defined you cannot call for its properties. Check if the column has value:

var attribute =  this.get("UsrAttributeName");

var attributeDisplayValue = attribute  && attribute.displayValue;

 

Please, let us know in case any additional information is required. 

 

Best regards,

Olga. 

Olga Avis,

Hi 

 

After debugging it turns out undefined is coming because Entity/Page is not fully loaded or when I create a new record then all fields are empty.

I could use your suggested way to assign attribute value to a variable but that would not be able to work if entity/page is not fully loaded.

 

So I used a flag in attributes with default value false and set it to true in OnEntityIntilized method.

Then I checked the flag, if it is true then the validation method will run.

 

Thanks

Ram

Show all comments

Hi All,

For an on going project, in the contact centre, when a customer calls and asks for certain specific service requests, few (3 to 5) security questions need to be asked (based on the category and service selected for the case) to validate that the customer himself is calling.

For this, we are having a lookup to keep the pool of questions. Can we have the answers (object and it's columns where the answers are populated) also captured in this lookup? 

For e.g. for question "What is the birth date?", can we record the answer to be checked against Contact (object) > birth date (column) ? 

Like 0

Like

2 comments

Dear Krishna, 



It would be much more convenient to create a separate detail which would contain all questions along with an answers and all needed information. 

By the way, can you please specify for which section you would like to add the described functionality? Cases or any other? 



Kind regards,

Roman

 

Roman Brown,

Thanks Roman for the inputs.

Yes I would like to add the questions connected with cases section.

 

I had created a detail for the same in cases (given below).

Also creating activity connected to cases to prompt agent to ask questions and capture the responses for these questions.

 

Is there anyway these questions can be asked one by one in a UI ?

 

Show all comments

Hi Community,

Any Idea how can I achieve below scenario in Mobile Application.

If case status is "closed", when saving record i need to show pop up message if there is no attachment. 

 

Like 0

Like

7 comments

Dear Fulgen,

You can achieve such task using push notifications for mobile application. Such push notifications are created via business process and corresponding  “Send push notifications” element.

By status change signal on the Case object you read the quantity on attachments on the record, which triggered process and based on the result you show push notification.

Check the following article on step-by-step implementation:

https://academy.bpmonline.com/documents/technic-bpms/7-14/how-set-push-notifications-mobile-application-users

Regards,

Anastasia

Anastasia Botezat,

Hi Anastasia, Thanks for your reply

Currently in mobile, we enable the status field in case form. So user can select the status to closed. Now when saving case record on mobile and if status is 'Closed', I need to do some validation if there is attachment in 'CaseFile'. This logic is achievable in web using esq to check if there are records in 'CaseFile' and use 'asyncValidate' method for validation. Now in mobile how can i implement the same logic? 

 

Fulgen Ninofranco,

Please check the following example. There is a query to Contact section, where we select Name, Id, Account. This is the corresponding to ESQ mobile version.

var store = Ext.create('Terrasoft.store.BaseStore', {
    model: 'Contact'
});
var queryConfig = Ext.create('Terrasoft.QueryConfig', {
    columns: ['Name', 'Id', 'Account'],
    modelName: 'Contact'
});
store.loadPage(1, {
    queryConfig: queryConfig,
    filters: Ext.create('Terrasoft.Filter', {
        property: 'Name',
        value: 'test'
    }),
    callback: function(records, operation, success) {
        var loadedRecord = records[0];
        if (loadedRecord) {
            var contact = loadedRecord.get('Account');                                                                                                    
            if (contact) {                                                                                                                   
                ...
            }
        }
    },
    scope: this
});

Regards,

Anastasia

Anastasia Botezat,

Hi Anastasia, Thanks for your reply

From which OOB Schema this source code is added?

Fulgen Ninofranco,

Also, here is an example of how to write direct query to database:

// sql requry to DB
var sqlText = "select pf.Id as ProductFolderId from ProductFolder pf " +
    "where pf.FolderTypeId = '9dc5f6e6-2a61-4de8-a059-de30f4e74f24' and " +
    "exists(select pif.Id from ProductInFolder pif where pif.FolderId = pf.Id and exists(" +
    "select p.Id from Product p where p.Id = pif.ProductId and " +
    " p.Active = 1 and p.TypeId = 'f1795fc3-36cc-4771-9222-178b339eb9f2'))";
 
// variable to which results will be stored
var records = [];
 
// executing query to DB
Terrasoft.Sql.DBExecutor.executeSql({
    sqls: [sqlText],
    success: function(data) {
        if (data.length &gt; 0) {
            var columnMap = {
                'ProductFolderId': 'Id'
            };
            var queryConfig = Ext.create('Terrasoft.QueryConfig', {
                modelName: 'ProductFolder',
                columns: ['Id']
            });
 
            var ids = data[0].rows;
            for (var i = 0, ln = ids.length; i &lt; ln; i++) {
                var sqlData = ids.item(i);
                var record = Terrasoft.SqlDataToRecordConverter.convert(sqlData, queryConfig, columnMap);
                records.push(record);
            }
        }
    }
});

You can check MobileCaseGridPageController, MobileActivityActionsUtilities schemas.

Regards,

Anastasia

Anastasia Botezat,

Hi Anastasia, Thanks for your reply

For 'asyncvalidate' method in web. What is its counterpart in mobile? I want to execute this esq on click of save button. So I need the same functionality as asyncvalidate in web.

Fulgen Ninofranco,

Unfortunately, there is no exactly same functionality for mobile application. However, you can use business rules instead. I have prepared an example of RegExp validation, hope it suits your task:

Terrasoft.sdk.Model.addBusinessRule('Contact', {
    ruleType: Terrasoft.RuleTypes.RegExp,
    regExp : /^([0-9\(\)\/\+ \-]*)$/
    triggeredByColumns: ['HomeNumber', 'BusinessNumber']
});

Regards,

Anastasia

Show all comments

Hi,

i would like to know how can i run Validations/Actions (like field validations) after i select an item  from a lookup list.

 

Like 1

Like

1 comments

Hello Pedro!



To set validator on some field, usually setValidationConfig method is used.

Validation method, that is set for some field, triggers each time the value in this field changes.



Article about it: https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-field-validation





If the task is to trigger custom validation methods on other fields it is achievable via dependencies. Please check the example of usage: https://community.bpmonline.com/questions/handler-dependant-detail-update



Best regards,

Alex

Show all comments

Hi;

Is it posible to add custom validation not connecting with any page but just run on page validation on Pre_configured page

Like 0

Like

4 comments

Hello,

Please describe the filter more precisely. Where it should work if it doesn't lie on a page. 

Hi;



When i have a condition base on many elements when I join it to one element it return error ena then when any other validation appear i got the message about wrong validation.

I would like to run validation just at the quiting the page and not asign it to any element

tomasz.branicki,

I'd write something like 

methods: {
			onTestClick: function() {},
			myValidation: function(callback, scope) {
				var resultObject = {
					success: false
				};
				callback.call(scope, [resultObject]);
			},
			asyncValidate: function(callback, scope) {
				this.callParent([function(result) {
					if (result.success) {
						this.myValidation(callback, scope);
					} else {
						callback.call(scope, result);
					}
				}, this]);
			}
		},

 

Eugene Podkovka,

 THANKS

 

Show all comments

Hello!

I have to do a validation in the Employee Registration, there can't be two employees with the same file number. For that, add a validation on the page and use ESQ to verify the data in the database.

The problem is that the result of the validation method is always executed before the result that ESQ GetEntityCollection() returns. I need to establish the error message after evaluating the result of the query.

Is there any way or alternative of waiting for the result of the ESQ and then validating to establish the error message?

I appreciate your help.

I Attach the code:

validarNroLegajo: function() {
    var invalidMessage = "";
	var repetidos = 0;
	//Creo consulta para Empleado
	var consultaEmpleado = this.Ext.create("Terrasoft.EntitySchemaQuery", {
		rootSchemaName: "Employee"
	});
	//Cuento NroLegajos
	consultaEmpleado.addAggregationSchemaColumn("UsrNroLegajo", Terrasoft.AggregationType.COUNT, "NroLegajoRepetido", Terrasoft.AggregationEvalType.ALL);
	//Filtro por Nro de legajo
	var filtroNroLegajo = consultaEmpleado.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "UsrNroLegajo", this.get("UsrNroLegajo"));
	//Filtro por Id de empleado
	var filtroId = consultaEmpleado.createColumnFilterWithParameter(Terrasoft.ComparisonType.NOT_EQUAL, "Id", this.get("Id"));
	//Agrego filtros a la consulta
	consultaEmpleado.filters.add("filtroNroLegajo", filtroNroLegajo);
	consultaEmpleado.filters.add("filtroId", filtroId);
	//debugger;
	consultaEmpleado.getEntityCollection(function(result) {
		debugger;
		if (result.success) {
				repetidos = result.collection.collection.items["0"].values.NroLegajoRepetido;
		}
	}, this);
	debugger;
	if (repetidos > 0)
	{
		invalidMessage = this.get("Resources.Strings.ValidacionNroLegajo");
	}
	return {
		// Validation error message displayed in the data window
		// when saving a page.
		fullInvalidMessage: invalidMessage,
		// Validation error message displayed under the control item.
		invalidMessage: invalidMessage
	};
}

 

Regards,

 

Like 0

Like

2 comments

Dear Ezequiel,

As you have already noticed, ESQ functions are asynchronous functions, therefore the validarNroLegajo function is executed before response received.   

In order to ensure, that a particular function or methods are executed based on the ESQ response, please call the function with invalid messages in the ESQ callback.

You can also create a virtual attribute, which you'll set to "true" in the ESQ callback. Such approach is also suitable, if you need to proceed with some actions based on the ESQ result.

 

//create an attribute
attributes: {
    "NumberDoesNotExist": {
        "type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
        "dataValueType": Terrasoft.DataValueType.BOOLEAN,
        "value": false
    }
}
 
//set attribute in the ESQ callback
 
 
...
select.getEntityCollection(function(response) {
    if (response.success) {
      var collection = result.collection;
      if (collection &amp;&amp; collection.collection.length === 0) {
       this.set("NumberDoesNotExist", true);
      } else {
        this.showInformationDialog("Error!");
      }
    }
}

Another option if to check during save() method based on the attribute, you can do the following:

save: function() {
    if(this.get("NumberDoesNotExist")) {
        this.callParent(arguments);
    } else {
        this.showInformationDialog("Error!");
    }
}

Hope you find this helpful.

Regards, 

Anastasia

Dear Anastasia, thanks for your help. I could solve the problem! Regards!

Show all comments

Hi All,

Is it possible to use setValidationConfig for two separate field on an edit page. Here is my code

setValidationConfig: function() {

this.callParent(arguments);

this.addColumnValidator("AtsLinkedProduct", this.relatedProductValidator);

this.addColumnValidator("AtsLata", this.relatedProductValidator);

},

 

relatedProductValidator: function(value) {

var invalidMessage = "";

var isValid = true;

var currentProduct = this.get("AtsLinkedProduct");

var currentLata = this.get("AtsLata");

var currentZone = this.get("AtsZone");

if (currentProduct && this.get("Products")) {

isValid = !(this.get("Products").indexOf(currentProduct.value) >= 0);

}

if (currentLata && this.get("Products.AtsLATA")) {

isValid = this.get("Products.AtsLATA") !== (currentLata.value);

}

if (!isValid) {

invalidMessage = this.get("Resources.Strings.RelatedProductExists");

}

return {

fullInvalidMessage: invalidMessage,

invalidMessage: invalidMessage

};

},

File attachments

Like

0 comments
Show all comments