How do you autopopulate a related field in custom module from a related field of another module?

I'm fighting against this issue since a couple of weeks and I can't figure out a way to do that.

I have a custom module for the orders management and I need to produce invoices automatically.
I'm following the example of 'ConverToInvoice.php' from Quotes module so, if I click on that button (under the Edit button in Detail View) I should create a new Invoice whose fields are pre-filled and  editable.
I have to grab fields' values from current order management.
My first problem is that a lot of those fields are related, too.

For example, I need to fill a related field called 'Suppliers' in my invoice. The value I need comes from a module (Suppliers) related to the Account, which is related to the current order management.

How can I easily grab that value and put it in my suppliers field?

I tryed to follow this guide  but it didn't worked.. probably I miss something.
I really need help, as soon as possible.

Thank you.

  • Thanks a lot for the answer!!!
  • Hi , I have a similar situation but i dont quite understand what you have shared above. For my situation , I need to get the fields from Points_management -"balance_points" and set it as default for the field in Transaction so each transaction i will be able to calculate and update back the Points_management. I dont know how to retrieve and update back the related modules vice versa. I really need help as I am new to SugarCRM. Thank  you everyone.
  • Will this work for SuiteCRM 7.2 also? I've been trying with your method so far but its always returning false
  • I am using it in v7.5.1.0 so it should work.
    Make sure you pass the module name, not the class and make the adjustment above to get back a list.

    FrancescaS
1 2