top of page

How to set Default Values on Link Pro on Espocrm

Updated: Apr 22, 2024

Some projects may need to have default values set for link multiple pro, here we show you how to do.


 
  1. First, add custom view to your field, see Espocrm docs.

  2. Here you can find the sample code for your custom view:

define('custom:views/order/fields/order-items', 'ebla-link-pro:views/fields/link-multiple-form', function (Dep) {

    return Dep.extend({

        afterRender: function () {
            Dep.prototype.afterRender.call(this);

            if (!this.model.isNew()  !this.form  this.mode === 'search' || this.mode === 'list') {
                return;
            }

            const defaultValue = [
                {
                    "name": "test",
                    "amount": 99,
                    "price": 35,
                    "assignedUserId": "6502d3b0ccc8bf8d3",
                },
                {
                    "name": "test 2",
                    "amount": 25,
                    "price": 32,
                    "assignedUserId": "6502d3b0ccc8bf8d3",
                },
                {
                    "name": "test 3",
                    "amount": 45,
                    "price": 75,
                    "assignedUserId": "6502d3b0ccc8bf8d3",
                },
                {
                    "name": "test 4",
                    "amount": 15,
                    "price": 25,
                    "assignedUserId": "6502d3b0ccc8bf8d3",
                }
            ];

            defaultValue.forEach((item) => {
                this.createRelated(item);
            });
        },
    });
});

Comments


©2020 by Eblasoft.

bottom of page