help with Logic Hooks

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • emillod
    replied
    If you want i can schedule a ms teams meeting, maybe you're doing something wrong.

    Leave a comment:


  • timarebel
    replied
    hello ;


    I already tried this , tried many ways but nothing for some reason not even log recored showing up ...bare in mind that my invoice Item is an entity itself .

    i just want to fetch this entity to Comission entity !!

    Leave a comment:


  • emillod
    replied
    I understand. No problem. We can do this with workflow. Here you have example: https://i.imgur.com/O6vnGT5.png
    I didn't added additional relations, but i assume that you did
    1. Remember about creating workflow for INVOICE ITEM
    2. Choose trigger After record created
    3. Condition - comission link in INVOICE can't be empty. In this case i don't have comission link in invoices, so i used quote Important: You have to choose in condition relation field IN INVOICES, not in invoice items
    4. Choose action: Update target record. Thanks to that you'll update invoice item with comission. Just choose to update field comission link in invoice items with field from invoices
    It should work

    Leave a comment:


  • timarebel
    replied
    i never used it , i m good at workflow but this one was tricky ! Do you have any recommendation where i can start with it ?

    Leave a comment:


  • emillod
    replied
    I preffer flowcharts, because it's more clear for me

    Leave a comment:


  • timarebel
    replied
    flowchart or workflow ?

    Leave a comment:


  • emillod
    replied
    Of course item is right, that your hook is incorrect, but i just propose to use advanced pack, it is easier.
    Flowchart should be assigned to InvoiceItem, then create rule which will trigger flowchart after creation, and just set update of entity, take comission from invoice which is parent for invoiceItem, and assign this comission to invoiceItem relation field.

    Leave a comment:


  • timarebel
    replied
    hello


    Thank you for the reply , if i understood well I have to enject the EntityManager first than follow with the relation ,it's a little bit advance for me as i just learning php so bare with my understanding !

    Leave a comment:


  • item
    replied
    Hello,
    you are wrong..

    hook is for entity ..
    you declare false first : https://docs.espocrm.com/development/hooks/#example
    your namespace is hook.. you extend repository...

    so you can only get "item" .. with relation like this :
    $opportunityCollection = $entityManager ->getRepository('Account') ->getRelation($account, 'opportunities') ->limit(0, 10) ->where($whereClause) ->find();

    see doc : https://docs.espocrm.com/development/

    regards

    Leave a comment:


  • timarebel
    replied
    i made the relation i even tried to use workflow but it's not working , maybe it's bug ?

    Leave a comment:


  • emillod
    replied
    Okay, in this case i think you should create new relation between comissions and invoiceItems. And you can assign invoiceItem with advanced pack to comission

    Leave a comment:


  • timarebel
    commented on 's reply
    i just posted the details i hope it's clear

  • timarebel
    replied
    hello and thank you for your answer ;


    i m trying to grab invoice items to show when i click on comission i show get it inside of the comission

    i tried to work around it with workflow but not getting anything back
    Attached Files

    Leave a comment:


  • emillod
    replied
    Hello. I think you're doing this wrong. Please give me more conext, i'll try to help you.

    Leave a comment:


  • timarebel
    started a topic help with Logic Hooks

    help with Logic Hooks

    hello

    I'm trying tofetch an entity to show in another entity is that possible with logic hook
    I have tried to use AfterSave but i m not sure if i did it right

    <?php
    namespace Espo\Custom\Hooks\Comission;
    use Application\Espo\Modules\Sales\Entities\InvoiceIte m;
    use Application\Espo\Modules\Sales\Entities\invoice;

    class product extends Espo\Core\ORM\Repositories\RDB
    {
    public function afterSave( Invoice $Invoice , array $InvoiceItem)
    {
    if ($invoice->isNew() && !$InvoiceItem->get('InvoiceItemId')) {
    $Comission->set('InvoiceItemId');
    }
    }
    }
    ?>
Working...