Long time Certified SugarCRM developer, first time SuiteCRM dev.
I’m trying to modify the fields in line items that appear on an invoice. I’ve added the 2 fields I want in Studio and cant find any option through Studio to do so. No big deal, I can find the files needed to modify this. Editing “Line Items” in Studio has the same effect as Sugar. It automatically creates the following folder:
Now in the Sugar world, there are 2 ways to handle this. Drop an empty “studio.php” into that folder, QRR and boom, off we go. GUI interface to reorder fields. This didnt work.
Second option is to move line_items.php and line_items.js into the custom folder and modify there to keep it upgrade safe. Only problem is, changes made there after a QRR are not being picked up. Only changes to the core module are being picked up which is usually a huge “no-no”.
If I go into Quotes in Studio, it lets me reorder the line items group layouts. Is this just a flaw in Suite? Is there an upgrade safe workaround? The file is ridiculously easy to modify but I especially want to make this a module loadable package and core modules are off limits through module loader. Also my changes would be wiped out during an upgrade. Ideas?
Did you also modified the vardef function value for line_items field in all 3 modules (Quotes, Invoices, Contracts) ? You would need to point the function to the new custom file in order for your changes to work. Let me know if that didn’t resolved your issue.
It also shows that once you get the Line_Items.php recognize, it includes code to search custom for any lineitems.js that exists there.
You still need to be careful when upgrading, to see if there are any changes to these files that you might need to integrate into your own. The upgrades installer will warn you of that.
That does work, and excuse me because again, I come from the “upgrade safe” world of SugarCRM. Modifying the file location in a base module to point to a custom folder kinda defeats the purpose. Any upgrades to those vardef files would break the pointers. Wouldn’t I need to modify the vardefs in the custom extension framework?
Something like
/custom/Extension/modules/AOS_Invoices/Ext/Vardefs/myNewCustomPointerFile.php
And add the override to the custom folder location there to make it TRULY upgrade safe? Can this be done? Has anyone tried?
Yes, all the talk about “upgrade-safe” is quite similar when moving from SugarCRM to SuiteCRM.
What is being suggested is what you describe - use the Extension Framework to change the vardefs. In those extended custom vardefs is where you point to the new PHP files.
Seems I’m still getting stuck. Maybe I can be pushed in the right direction? Suite is picking up my extension but not fully overriding the dictionary element I want. It’s trying to redeclare it twice. Once from the normal directory and again from the custom directory.
Step 1:
Copied /modules/AOS_Products_Quotes/Line_Items.php to custom/modules/AOS_Products_Quotes/Line_Items.php
Step 2:
created file called ´_override_vardefs.phpincustom/Extension/modules/AOS_Invoices//Ext/Vardefs/`
Step 3:
Populated _override_vardefs.php with the following code
Step 4: Executed QRR
Now when I go to an invoice, I get an Ajax error and the invoice page wont load.
Looking at my httpd error_log I have the following error:
PHP Fatal error: Cannot redeclare display_lines()
(previously declared in /var/www/html/SSIDemo/custom/modules
/AOS_Products_Quotes/Line_Items.php:25) in /var/www/html/SSIDemo/modules
/AOS_Products_Quotes/Line_Items.php on line 222,
referer: http://192.168.1.157/SSIDemo/index.php?action=ajaxui
No dice there either by changing the “display_lines” to something else. Here’s the httpd error. This did however push me to the final upgrade safe solution.
PHP Warning: call_user_func() expects parameter 1 to be a valid callback, function ‘custom_display_lines’ not found or invalid function name
This error set off a light bulb and FINALLY figured this out, and wow this was unnecessarily complicated. There is probably an easier way to do this, but this works… Here is the upgrade safe way to override the line items panel in the AOS_Invoice module. Thank you everyone for pushing me in the right direction…
Step 1:
Copy /modules/AOS_Products_Quotes/Line_Items.php to custom/modules/AOS_Products_Quotes/Line_Items.php
Step 2:
Create file called ´_override_vardefs.php in custom/Extension/modules/AOS_Invoices/Ext/Vardefs/`
Step 3:
Populate _override_vardefs.php with the following code