Announcement

Collapse
No announcement yet.

Calling a service method from another service. [ESPO Upgrade 6.1.0 -> 7.0.10]

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

  • Calling a service method from another service. [ESPO Upgrade 6.1.0 -> 7.0.10]

    Previously I was doing:
    From Contact service:
    Code:
    $this->getRecordService('ClientDetail')->update($clientDetailEntity->id, $clientDetails);
    to update the ClientDetail.

    But since getRecordService method is deprecated, how do I call the functions from another service? Do I have to import the class and call the method?

    There is no documentation regarding this anywhere.

    telecastg item Any help would be appreciated.

  • #2
    Hello,

    Try the solution posted here: https://forum.espocrm.com/forum/inst...5922#post75922

    Comment


    • #3
      Hello,
      my knowledge is old (bad certainly).. now if i understand, you can call anything from anything..
      i have not understand DI ...maybe if i undertand english
      but this work..

      look this : https://github.com/hturkoz/espocrm-h...ae4eb3921823ba
      look full file.. construct..

      $myService = $this->serviceFactory->create('MyService');
      $myService->process( $myData->getRaw() );

      so you can call any service from any other place
      Yuri is incredible
      Last edited by item; 04-13-2022, 08:13 PM.

      Comment


      • #4
        Record services are the layer for CRUD operations being made via API. So I wouldn't recommend using them in business logic.

        From the record service:
        PHP Code:
        $anotherRecordService $this->recordServiceContainer->get($entityType); 

        Comment


        • telecastg
          telecastg commented
          Editing a comment
          I will include a link to this post in my adapting to Espo 7 post, it's nice to have an example of the correct usage of Espo 7 re-designed features.
      Working...
      X