Announcement

Collapse
No announcement yet.

how to set Entity teams via js

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

  • iioi
    replied
    Originally posted by item View Post
    Hi,
    try this ..maybe use "this" :

    var modelData = {};
    modelData.teamsIds = model1.get('teamsIds') || [];
    modelData.teamsNames = model1.get('teamsNames') || {};
    model.set(modelData);
    Thsnks a lot! It works!

    Leave a comment:


  • item
    replied
    Hi,
    try this ..maybe use "this" :

    var modelData = {};
    modelData.teamsIds = model1.get('teamsIds') || [];
    modelData.teamsNames = model1.get('teamsNames') || {};
    model.set(modelData);

    Leave a comment:


  • iioi
    replied
    Originally posted by rabii View Post
    try this

    Code:
    this.model.set('teamsNames',Names);
    this.model.set('teamsNames',Names); , where Names is Object 62a0627f2adfff704: "TEST1"

    it does not change teams label

    Leave a comment:


  • rabii
    replied
    try this

    Code:
    this.model.set('teamsNames',Names);

    Leave a comment:


  • iioi
    replied
    I've tried this. No result.

    Leave a comment:


  • rabii
    replied
    you can try and set the teamsIds instead of teamsNames.

    Leave a comment:


  • iioi
    replied
    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:


  • Vadym
    replied
    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-fields

    Leave a comment:


  • iioi
    started a topic how to set Entity teams via js

    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));
    });
Working...
X