Calculate Field Values in Products Editview

I have created logic_hooks to perform various calculations on this form to give me a final selling price on a particular product when we save the record.

I would like to know whether it would be possible to create a button next to the Selling Price field e.g Calculate that will execute the logic_hooks. At this stage as mentioned you have to first save the record before the system calculates all the respective fields.

We would like the user to be able edit the Product, make changes to values in certain fields in EditView, click on calculate, the logic_hooks are executed and the new calculated values is displayed in the Selling Price field. Once they are happy with the Selling Price result they can just save the Product record.

Unfortunately my development skills are fairly limited so if possible code examples or even references to other examples will be much appreciated

Hi Botteljie,

You can do this utilising JavaScript/AJAX to call your hook before the record is saved.

Thanks,

Will.

Hi Will, thank you.

I’m not experienced with this.

Could you give me any advice about what objects i’llbe able to manipulate with a js function?

I would remove the logic hook in your place and create the listeners on the elements that would call the custom coded entryPoint in SuiteCRM and execute the logic_hook code you have already written.

With js you can manipulate the DOM objects, but if you establish communication with the server using AJAX as mentioned you can pretty much calculate/change anything you need.