Question

Can anyone know about popup on Leads section with same email address.

I need one popup like email is already exists  if the email will be same while adding the new lead on lead section. 

Here the code i was written but it is not applying can anyone help on this.

define("LeadMiniPage", [], function() {
    return {
        entitySchemaName: "Lead",
        details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/,
       attributes: {
            "Email": {
                dataValueType: Terrasoft.DataValueType.TEXT,
                dependencies: [
                    {
                        columns: ["Email"],
                        methodName: "validateEmail"
                    }
                ]
            },
        methods: {
            
            validateForm: function() {
                    
                    var recordEmail = this.get("Email");
                    var message = "";
                    //Validate when phone is not nul or empty
                //Validate when email is not nul or empty
                    if(recordEmail !== null && recordEmail !== "" && recordEmail !== undefined) 
                    {
                    //    var emailMessage = "";
                        var emailesq = this.Ext.create("Terrasoft.EntitySchemaQuery", {
                            rootSchemaName: "Lead"
                        });
                        
                        
                        emailesq.addColumn("Email", "Email");
                        
                        var esqEmailFilter = emailesq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, 
                                                    "Email", recordEmail);
                                                    
                        emailesq.filters.add(esqEmailFilter);
                        
                        emailesq.getEntityCollection(function (result) {
                            if (!result.success) {
                                this.showInformationDialog("Data query error");
                                return false;
                            }
                            else{
                                result.collection.each(function (item) {
                                    message = message + "Email " + item.get("Email");
                                 //   return false;
                                });
                                
                            }
                            
                            if(message !== ""){
                                this.showInformationDialog(message);
                            }
                            
                        }, this);
                        
                        
                    }
                    
                    
                    
            }
        },
        // Visual display of the [UsrBalance] column on the edit page.
        diff: /**SCHEMA_DIFF*/[
            
            
        ] /**SCHEMA_DIFF*/
}
};
});

Like 0

Like

3 comments

The problem is the esq to check for other conflicting emails is asynchonous. You'll need to create a flow to check for when your validation has completed before the page's base save function is called. 

See the responses from Anastasia in this thread for an overview of how the flow should work. You'll need to implement something similar. https://community.bpmonline.com/questions/cant-return-validation-message

Ryan

We do this in another way:

When bpm'online find contacts or accounts with similar e-mail, it offers to choose one of them in the list

Hello praveen,

Please note on Ryan`s comment. 
Also, if I understood right    if (!result.success)  this check is used to understand if the query returned something or not.
But this property shows only if the query was successful and processed without any errors, so empty array is a successful result too. Due to this, you should add one more check of items property.

I recommend you to debug the method validate form to understand if the code do exactly what you need. 

Best regards,
Alex

Show all comments