Auto fill field in module SuiteCRM

Hi all,
I have 4 field (Quantity, Price, Tax, Amount), i want to auto fill Amount when user input another fields. I also want that, any change of Quantity or Price or Tax field in Create View (or Edit View) then automatic change Amount field. Please help me!

That requires some development. Look for posts explaining how to inject some Javascript into an Edit view.

Then you can make your custom Javascript do those things easily.

1 Like

Thanks for your help. I added successful my custom js. But it works OK in Create View, however it work wrong in Edit View because when i click edit record, suitecrm has redirect website to index.php, therefore my javascript is undefined in index.php.
I do not know why when i click edit record in my module, suitecrm was redirected instead of redriect to editview in custom/modules/my_module/medata/editviewdefs.php.
Thanks,

How exactly did you add the code? If you are overriding the display class of the Edit view of your module, then your javascript injection should always happen when the edit view is being displayed, no matter where you’re coming from…

Hi,
To adding custom js, i included my code in to 2 files (editviewdef, createviewdef)

'includes' => array(
				0 => array(
					'file' => 'custom/modules/vtl_Debt/jquery-3.3.1.min.js',
					'file' => 'custom/modules/vtl_Debt/myscript.js',
				),
			),

It works pefectly in Createview but Editview is not work. I do not know why when i edit record, suitecrm will automatic redriect to index.php insted of editview page.
Please help me!

You should not include jquery - SuiteCRM already does that.

… and keep an eye on php_errors.log, or whatever your web server log is called, there’s very likely a FATAL error there.

I also known that suiteCRM already included jquery, but i were not used jqurey functions, so i included jquery and have done.

… but that is not an errror. It still working and no error found in php_errors.log :frowning:

Ok, so if you need help with your code, then post your code, and explain any error messages or unintended behaviours.

I have a question, i do not know why suitecrm works incorrect.

  1. I have customed editdef.php and createdef view page for add my javascript file by code below

'includes' => array(
				0 => array(
					'file' => 'custom/modules/vtl_Debt/jquery-3.3.1.min.js',
					'file' => 'custom/modules/vtl_Debt/myscript.js',
				),
			),
  1. And after that, when i edit record, suitecrm will redriect to index.php instead of edit view.
  2. Because suitecrm runing index.php, so my javascript is not working. Please explain me why suitecrm redriected?

Are you sure your php_errors.log is operational? Usually there are a lot of messages there, from other small things (deprecateds, infos, etc.). Are you seeing those? I just want to make sure you are looking at the correct file, and that the log is enabled.

You can also raise your suitecrm.log level to DEBUG in Admin / System settings, that might give you further clues.

And remove that jquery include, it’s not necessary.