Announcement

Collapse
No announcement yet.

How to add a confirmation message before selecting / relating a record.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to add a confirmation message before selecting / relating a record.

    Hi all,


    Just thought would share this in case someone needs it. If you have a 1:n relationship and want to add a confirm message when selecting related records, you can do it as below. Let us take Account and Contact entities. Let us say that you want to add a confirmation message (are sure you want to relate the selected contacts?) If the user clicks Yes the selected records are linked.

    1 - Under custom folder create Contact.json under custom/Espo/Custom/Resources/metadata/clientDefs to customise the select modalViews of the contact
    PHP Code:
    {
        
    "modalViews": {
            
    "select""custom:views/contact/modals/select"
        
    }


    2 Now create the new custom view under client/custom/src/views/contact/modal/select.js and use code below which extends the relationship view.
    PHP Code:
    define('custom:views/contact/modals/select',
        [
    'views/modals/select-records'], function (Dep) {

        return 
    Dep.extend({

            
    setup: function () {
                
    this.filterList = ['active'];
                 
    // Here you can set up filters to apply to the select modal etc...
                
    if (this.getAcl().getPermissionLevel('portalPermission')) {
                    
    this.filterList.push('activePortal');
                }

                
    Dep.prototype.setup.call(this);
            },

            
    actionSelect: function () {

                
    this.confirm({
                    
    messagethis.translate('linkSelectedRecordsConfirmation''messages'),
                    
    backdrop'static',
                    
    confirmTextthis.translate('Select & Link'),
                }).
    then(() => {
                    
    Dep.prototype.actionSelect.call(this);
                });
            }
        });  
    });
    ​ 

    Et voila now if you save this clear cache and rebuild and go to the an existing account and try to relate / select contacts you should see the confirmation message one clicked on select button.

    The only downside of this is that this will be applied to all selection of contacts through other entities. I will share an update code once i figure out how to apply this to only one specific entity.​

    Hope this helps

    Best regards,
Working...
X