how to set Entity teams via js
Collapse
X
-
Hi,
try this ..maybe use "this" :
var modelData = {};
modelData.teamsIds = model1.get('teamsIds') || [];
modelData.teamsNames = model1.get('teamsNames') || {};
model.set(modelData);Leave a comment:
-
-
Customer select user, and i want to set Entity teams by user teams. I handle user selection, by i can't set teams in JS code.Leave a comment:
-
Hi iioi,
Could you tell me in more detail what logic you are trying to achieve?
Perhaps it can be realized by Formula?
If yes, I will be happy to assist.
Documentation:
https://docs.espocrm.com/administrat...culated-fieldsLeave a comment:
-
how to set Entity teams via js
Please, how to set teams via js ?
I what to set entity teams by user teams
I try to set teamsNames and teamsIds, only teamsNames and so on.
The result in attach
full code (last version):
this.listenTo(this.model, 'change', (model, options) => {
debugger;
if (this.model.hasChanged('assignedUserId')) {
// someAttribute is changed
this.getModelFactory().create('User', function (model1) {
model1.id =model.get('assignedUserId');
model1.fetch().then(function () {
debugger;
var teamsNames = model1.get('teamsNames');
Names = Object.values(teamsNames);
model.set('teamsNames',Names);
model.set('teamsIds',model1.get('teamsIds'));
console.log(model1); // it's fetched
}.bind(this));
});1 PhotoTags: None
Leave a comment: