How to find record on front end

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rabii
    Active Community Member
    • Jun 2016
    • 1250

    How to find record on front end

    Hi Guys,

    Does anyone know how can i retrieve data from database from front-end specifically from a view, how can the code below be translated into front-end javascript code:

    Code:
    $collection = $entityManager ->getRDBRepository($entityType) ->where([ // where clause 'type' => 'Customer', ]) ->find();
    Any help please. telecastg emillod item

    thanks
    Rabii
    Web Dev
  • item
    Active Community Member
    • Mar 2017
    • 1476

    #2
    Hi,
    maybe : https://github.com/espocrm/espocrm/s...lectionFactory
    front-end is very difficult for me .. now back-end too

    Find this too :



    Last edited by item; 07-04-2022, 08:05 PM.
    If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #3
      Many thanks i will have a look.
      Rabii
      Web Dev

      Comment


      • item
        item commented
        Editing a comment
        Hello Rabii, please if you find a working solution, post your solution.

      • rabii
        rabii commented
        Editing a comment
        sure i will share if i figure out how to do it.
    • telecastg
      Active Community Member
      • Jun 2018
      • 907

      #4
      Hello,

      Try this code in your view script:

      Code:
      // specify the scope
      const entityType = "your-entity";
      
      // specify the fields (table columns) that you wish to retrieve from the back-end as a comma separated string.
      const columnNameList = "field-1, field-2, field-n";
      
      // create a collection to hold the list of models (records) that will be retrieved from the back-end
      this.getCollectionFactory().create(entityType, (myCollection) => {
          myCollection.data.select = columnNameList;
          myCollection.whereAdditional = {field: "type", type: "equals", value: "Customer"};
      
          // display the new collection object in the console so you can see its structure and use its attributes as desired
          console.log("myCollection = ",myCollection);
      
          // Be mindful of Javascript's asynchronous nature, "myCollection" will not exist until this moment. If you reference "myCollection" outside the scope of this function, it might not exist yet. To address this issue, you can use promises or callbacks.
      
      }, this);

      Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1250

      #5
      got you i am familiar with promise but never seen the part of the documentation. many thanks for putting me into the right direction.
      Rabii
      Web Dev

      Comment


      • telecastg
        telecastg commented
        Editing a comment
        You're welcome
    Working...