The exact way to customize Vardefs

Hi to all,
I have already successfully modified the line_items fields in AOS_Products_Quotes (in this case I added discounts).
Now I would also like to update my Line_Items.php but, to proceed, I need to override the two include that are in AOS_Quotes/vardefs.php which now point to modules/AOS_Products_Quotes/Line_Items.php and instead should point to custom/modules/AOS_Products_Quotes/Line_Items.php.

So, after reading the documentation and many threads, I still can’t figure out which is the right way (and where to place the file). Because, if Vardefs is not updated correctly, it is removed at the first repair.

Can anyone clarify this point?
Thanks in advance.

Try in

custom\Extension\modules\AOS_Products_Quotes\Ext\Vardefs\vardefs.ext.php

see here for details on the Extension mechanism: https://docs.suitecrm.com/developer/extension-framework/

I have already tried but maybe in the wrong way.
In fact from the examples I can understand how to do when I have to add a feature but in this case I have to overwrite it.

So for line_items I think it should look like something but it’s not certainly correct.

line_items_ext.php


<?php
 // created: 2019-09-26 08:45:31
$dictionary['AOS_Products_Quotes']['fields']['line_items']['function']=> array(
                        'name' => 'display_lines',
                        'returns' => 'html',
                        'include' => 'custom/modules/AOS_Products_Quotes/Line_Items.php'
                    ),

 ?>

Or should I put all the complete vardefs by modifying only the includes?

Thanks for the support.

UPDATE:

If I put in custom\Extension\modules\AOS_Quotes\Ext\Vardefs\change_includes.php


<?php
$dictionary['AOS_Quotes']['fields']['line_items']['function'] ['include'] = 'custom/modules/AOS_Products_Quotes/Line_Items.php';
$dictionary['AOS_Quotes']['fields']['shipping_tax_amt']['function'] ['include'] = 'custom/modules/AOS_Products_Quotes/Line_Items.php';
 ?>

something happens because if I click on the quotes list in front end a white “undefinited” popup will open. Even if the line_items.php file is the same as the original. But at the moment, I still don’t understand the problem.

Now I’m starting to see what you’re trying to do, but sorry, I don’t think your approach is the correct one.

Let’s get back to the start… why do you think you need to change the vardefs? Is it just to get a custom Line_Items.php recognized?

Yes exactly. I would like to do this by modifying everything on the right way as I have done so far, without modifying the original files. Is this override of the include not possible? Thanks for the answers.

Hhhmm can you try removing that space between function and include?

Ok sorry if I can only answer now.

So, I uploaded my file inside
custom\Extension\modules\AOS_Quotes\Ext\Vardefs change_includes.php
and, in effect, removing the empty spaces and after a Quick Repair, now I find the file
vardefs.ext.php
inside custom\modules\AOS_Quotes\Ext\Vardefs with the following code


<?php 
 //WARNING: The contents of this file are auto-generated


$dictionary['AOS_Quotes']['fields']['line_items']['function']['include'] = 'custom/modules/AOS_Products_Quotes/Line_Items.php';
$dictionary['AOS_Quotes']['fields']['shipping_tax_amt']['function']['include'] = 'custom/modules/AOS_Products_Quotes/Line_Items.php';
 
?>

So something has been done.

However now the file Line_Items.php in custom is the same as the originall but if I click on an item in the list view (in quotes but also in account) I receive an undefinited popup, without being able to see an error (see attachment).

You should have an error message in one of your logs.

Make sure that the ownerships and the permissions of the new files, and any files you are editing, are correct, so that the web server can read them.

Ok, I’ll take a look. Thanks for your support.
Given that the main problem with this thread has been solved, it can be closed.

Hi and sorry if I bring this thread up again.
I’m pretty worried because I can’t get through this situation.

So, to recap:

  • I have successfully modified the line.items.js file in AOS_Products_Quotes custom folder
  • I have a modified and running line_itemes.php (because if I use it in the original folder of the AOS_Products_Quotes module there is no errors)
  • I managed to generate the Vardefs indicated in the previous post to overwrite includes and use my own line_items.php (at least it seems like the result is correct)

but, if I put my line_items.php in the AOS_Products_Quotes custon folder, after having generated the extension to Vardefs, I receive that undefinited white popup.

If I look at the logs, I get the following two lines that don’t help


Thu Oct  3 10:57:14 2019 [9149][1][WARN] Saving error level. Try to remove the error_reporting() function from your code.
Thu Oct  3 10:57:14 2019 [9149][1][ERROR] Pop error level. Try to remove the error_reporting() function from your code.

In console, I see the errors attached.

I can’t activate php.ini on the server so I have no idea about the problem.

Any suggestions are welcome. Thanks.

Well, I solved all my problems!
The same procedure for customizing vardefs must also be done with AOS_Contracts and AOS_Invoices modules.

I hope this post of mine is also helpful to others.

Thanks to all.

2 Likes