Announcement

Collapse
No announcement yet.

How to set description field of main object with description field of related objects

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

  • How to set description field of main object with description field of related objects

    How to set description field of main object with description field of related objects when select related object ?
    (Please find screenshot in attach)

  • #2
    Hi,
    If you have a relation 'A_test1 to A_test2' of Many-to-One type, you can try to utilize the next formula for the A_test1 entity:
    Code:
    ifThen(
        entity\isAttributeChanged('aTest2Id'),
        description = aTest2.description
    )
    Last edited by Maximus; 08-16-2019, 07:35 AM.

    Comment


    • #3
      Description field changed after page saved. Can it be changed immediately when ATest2 changed ? (screenshot in attach)
      Attached Files
      Last edited by Aleksis; 08-24-2019, 07:48 AM.

      Comment


      • #4
        You can investigate a source code of the js files with similar dynamic changes and create your own.
        This can be helpful https://github.com/espocrm/documenta...opment/view.md.

        Comment


        • #5
          I'm very much sorry - I didn't find any page with the same dynamic changes. Can you please name one ?

          For now I customize link field using https://github.com/espocrm/documenta...dard-fields.md

          It seems I have to handle event, but I can't find what event.
          Last edited by Aleksis; 08-27-2019, 08:27 AM.

          Comment


          • #6
            The solution.
            1. customize link field using https://github.com/espocrm/documenta...dard-fields.md
            2. Extend select:

            Code:
            return Dep.extend({
            
            select: function (model) {
            debugger;
            this.$elementName.val(model.get('name'));
            this.$elementId.val(model.get('id'));
            [I]try
            {
                if (this.attributeList.length > 1 )
                {
                   cc = this.attributeList[1];
                   if (cc == "aTest2Name")
                   {
                        rr1 = this._parentView;
                        rr1.model.set('description',model.get('description '));
                   }
                }
            }
            catch (e) {
            
            }
            
            debugger;[/I]
            if (this.mode === 'search') {
            this.searchData.idValue = model.get('id');
            this.searchData.nameValue = model.get('name');
            }
            this.trigger('change');
            },
            Last edited by Aleksis; 08-31-2019, 06:01 PM.

            Comment

            Working...
            X