help with Logic Hooks
Collapse
X
-
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:
-
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- Remember about creating workflow for INVOICE ITEM
- Choose trigger After record created
- 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
- 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
Leave a comment:
-
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:
-
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:
-
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:
-
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:
-
i made the relation i even tried to use workflow but it's not working , maybe it's bug ?Leave a comment:
-
Okay, in this case i think you should create new relation between comissions and invoiceItems. And you can assign invoiceItem with advanced pack to comissionLeave a comment:
-
-
Hello. I think you're doing this wrong. Please give me more conext, i'll try to help you.Leave a comment:
-
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');
}
}
}
?>
Tags: None
Leave a comment: