Announcement

Collapse
No announcement yet.

how to set Entity teams via js

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

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

  • #2
    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

    Comment


    • #3
      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.

      Comment


      • #4
        you can try and set the teamsIds instead of teamsNames.

        Comment


        • #5
          I've tried this. No result.

          Comment


          • #6
            try this

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

            Comment


            • #7
              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

              Comment


              • #8
                Hi,
                try this ..maybe use "this" :

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

                Comment


                • #9
                  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!

                  Comment

                  Working...
                  X