Access data from view of custom field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kertys
    Junior Member
    • Nov 2018
    • 8

    Access data from view of custom field

    Good day.

    There are two entities:

    Entity1
    - Field1
    - Relation One-to-many Entity2

    Entity2
    - Field2
    - CustomField
    - Relation Many-to-one Entity1

    Please tell me - how can I access the data of Field1 and Field2 from the view of a custom field? (Custom: views/fields/CustomField.js)
    If possible, a small example, please.
    Last edited by kertys; 11-19-2019, 07:55 AM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Hi,

    I recommend to create a a foreign in Entity2 for Field1.

    Then you will be able to access it with this.model.get('foreignFieldName');


    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • kertys
      Junior Member
      • Nov 2018
      • 8

      #3
      Thanks, everything works great!

      Comment

      • kertys
        Junior Member
        • Nov 2018
        • 8

        #4

        And one more question about views/fields/CustomField.js

        I need to set the value of CustomField from a third-party custom bash script, the result of which is displayed in stdout.
        I try this design:
        ===
        const execFile = require ('child_process').execFile;
        var data = execFile('myscript.sh', ['arg1', 'arg2'], (error, stdout, stderr) => {
        if (error) {
        throw error;
        }
        console.log (stdout); });
        ===
        but it does not work
        Please tell me how to do this?

        Comment

        Working...