Announcement

Collapse
No announcement yet.

Custom Print to PDF button and Dynamic filters (getSelectFilters)

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

  • Custom Print to PDF button and Dynamic filters (getSelectFilters)

    Hello lads,

    I'm looking for dev help regarding 2 functionalities:

    1. Custom Print to PDF button in the top right (views/detail)

    I have been trying to do this simple task by following both the documentation and ALL the threads here without any success. My button appears in the Detail view but unfortunately throws several different JS errors when clicked. I have tried to implement this by both custom handler and custom views.
    The expected behavior after clicking on the custom button is to open the template modal selection and create the PDF document after template selection.
    Other expected behavior would be to skip the template selection and directly open the generated PDF based on predefined templateId.

    2. Custom dynamic search filters via getSelectFilters

    I have been trying for 2 days to copy the same logic as in Accounts/Contacts/Opportunities/Quotes for dynamic filtering based on other fields.

    /custom/Espo/Custom/Resources/metadata/clientDefs/Claim.json:

    Code:
    {
    "controller": "controllers/record",
    "boolFilterList": [
    "onlyMy"
    ],
    "iconClass": "far fa-money-bill-alt",
    "kanbanViewMode": false,
    "dynamicLogic": {
    "fields": {
    "insurancePolicy": {
    "view": "custom:views/claim/fields/insurance-policy"
    },
    "claimChecklist": {
    "visible": {
    "conditionGroup": [
    {
    "type": "equals",
    "attribute": "insuranceProductId",
    "data": {
    "field": "insuranceProduct",
    "values": {
    "insuranceProductName": "MTPL"
    }
    },
    "value": "5fa28ab7221a524f5"
    }
    ]
    }
    }
    }
    }
    }
    /client/custom/src/views/claim/fields/insurance-policy.js

    Code:
    Espo.define('custom:views/claim/fields/insurance-policy', 'views/fields/link', function (Dep) {
    
    return Dep.extend({
    
    setup: function () {
    Dep.prototype.setup.call(this);
    // some initialization
    },
    
    getSelectFilters: function () {
    if (this.model.get('accountId')) {
    var nameHash = {};
    nameHash[this.model.get('accountId')] = this.model.get('accountName');
    return {
    'account': {
    type: 'linkedWith',
    value: [this.model.get('accountId')],
    data: {
    type: 'anyOf',
    nameHash: nameHash,
    }
    }
    };
    }
    },
    
    getCreateAttributes: function () {
    if (this.model.get('accountId')) {
    return {
    accountId: this.model.get('accountId'),
    accountName: this.model.get('accountName')
    }
    }
    },
    });
    });
    Any help would be appreciated!

  • #2
    You didn't add everything in regard to issue with PDF button. You have to map your custom client folder in clientDefs, and after that you have to create this button in custom client directory.

    Comment


    • #3
      Any help in regards to the PDF button in details view? Please.

      Comment


      • #4
        If you want, you can send us an email, and we'll estimate this for you.

        Comment

        Working...
        X