top of page

How to set Default Values on Link Pro on Espocrm

Updated: Apr 22

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);
            });
        },
    });
});

77 views0 comments

Recent Posts

See All

Commentaires


bottom of page