Announcement

Collapse
No announcement yet.

Custom button visibility control

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

  • Custom button visibility control

    I have created a custom button
    Code:
    custom/Espo/Custom/Resources/metadata/clientDefs/Email.json
    and a handler class
    Code:
    client/custom/src/createProductionHandler.js
    Everything works fine except for a visibility part where I have to check if Parent has some field set or not.
    Code:
    isCreateProductionVisible() {
    
    if ((this.view.model.get('parentType') == 'Order') && this.view.model.get('parentId'))
    {
    Espo.Ajax.getRequest('Order/' + this.view.model.get('parentId')).then(order => {
    if (order.productionId)
    {
    console.log('Has Production');
    return false;
    }
    else
    {
    console.log('Doesnt have Production');
    return true;
    }
    
    });
    
    }
    console.log('Leaving visibility check');
    return !((this.view.model.get('parentType') == 'Production') && this.view.model.get('parentId'));
    
    }
    The problem is that
    Code:
    isCreateProductionVisible
    returns before
    Code:
    Espo.Ajax.getRequest
    completes.

  • #2
    Try calling this.view.model.trigger('sync'), this will mimic the model being saved or fetched and will force visibility update.

    Comment


    • #3
      Ok, that's it. Thanks

      Comment

      Working...
      X