Announcement

Collapse
No announcement yet.

How to find record on front end

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

  • 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

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

    Comment


    • #3
      Many thanks i will have a look.

      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.

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


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

      Comment


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