Hi,
I'm working trying to filter, under Sales Order entity, depending on the Account selected, a filtered contact.
I've read I have to update the following:
Under /custom/Espo/Custom/Resources/metadata/entityDefs/SalesOrder.json
FROM THIS:
},
"contact": {
"type": "link"
TO THIS:
"contact": {
"type": "link",
"view": "crm:views/case/fields/contact"
},
"contacts": {
"type": "linkMultiple",
"view": "crm:views/case/fields/contacts",
"orderBy": "name",
"detailLayoutIncompatibleFieldList": ["contact"]
AND FROM THIS:
"contact": {
"type": "belongsTo",
"foreign": "salesOrders",
"entity": "Contact",
"audited": false,
"isCustom": true
}
TO THIS:
"contact": {
"type": "belongsTo",
"foreign": "salesOrders",
"entity": "Contact",
"audited": false,
"isCustom": true
},
"contacts": {
"type": "hasMany",
"entity": "Contact",
"foreign": "Accounts",
"layoutRelationshipsDisabled": true
}
Also, I have to modify the file (creating the path since it doesn't exists):
/client/modules/crm/src/views/case/fields/contacts.js
Adding the following code:
define('crm:views/SalesOrder/fields/contacts', 'views/fields/link-multiple-with-primary', function (Dep) {
return Dep.extend({
primaryLink: 'contact',
getSelectFilters: function () {
if (this.model.get('accountId')) {
var nameHash = {};
nameHash[this.model.get('accountId')] = this.model.get('accountName');
return {
'accounts': {
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')
}
}
}
});
});
the links I used to create this are:
But I can't get this work; Can somebody help me and know what is wrong with the code?
Maybe I have to do something different since it is on a Sales Package, but I don't know.
Thank you!
I'm working trying to filter, under Sales Order entity, depending on the Account selected, a filtered contact.
I've read I have to update the following:
Under /custom/Espo/Custom/Resources/metadata/entityDefs/SalesOrder.json
FROM THIS:
},
"contact": {
"type": "link"
TO THIS:
"contact": {
"type": "link",
"view": "crm:views/case/fields/contact"
},
"contacts": {
"type": "linkMultiple",
"view": "crm:views/case/fields/contacts",
"orderBy": "name",
"detailLayoutIncompatibleFieldList": ["contact"]
AND FROM THIS:
"contact": {
"type": "belongsTo",
"foreign": "salesOrders",
"entity": "Contact",
"audited": false,
"isCustom": true
}
TO THIS:
"contact": {
"type": "belongsTo",
"foreign": "salesOrders",
"entity": "Contact",
"audited": false,
"isCustom": true
},
"contacts": {
"type": "hasMany",
"entity": "Contact",
"foreign": "Accounts",
"layoutRelationshipsDisabled": true
}
Also, I have to modify the file (creating the path since it doesn't exists):
/client/modules/crm/src/views/case/fields/contacts.js
Adding the following code:
define('crm:views/SalesOrder/fields/contacts', 'views/fields/link-multiple-with-primary', function (Dep) {
return Dep.extend({
primaryLink: 'contact',
getSelectFilters: function () {
if (this.model.get('accountId')) {
var nameHash = {};
nameHash[this.model.get('accountId')] = this.model.get('accountName');
return {
'accounts': {
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')
}
}
}
});
});
the links I used to create this are:
But I can't get this work; Can somebody help me and know what is wrong with the code?
Maybe I have to do something different since it is on a Sales Package, but I don't know.
Thank you!
Comment