How do you add js to a record edit view in Sugar7?

before, I will wrote some js files and include them in editviewdef.php,and everything was fine,like 'displayParams' , $.ajax to get values .However ,when I fall in Sugar7,it seems that even I want to alert('hello') is a problem.

Now, I hope someone kind could give an method to include js file . specifically,in account ,I can use formula to make field A = filed B+ field C, but the field A can not be edit for using formula.I would use js to calculate it in th pass ,and certainly it could be edit .Now, how should I do?

Thanks


Parents
  • If you customize the record view (clients/base/views/record) HandleBars for example and include a JavaScript tag there for example. A better solution is to extend the controller and try to add all module specific clientside functionality there.

    But for the issue you try to solve: you want that the value of field A is equal to B+C. This can be done by creating a formula for Field A, but you do not want to do this because it makes the field not editable anymore (so Field A is some sort of default value?) ? In that case then maybe a Logic Hook might be a better solution, for example a before_Save logic hook which sets the appropriate value for Field A before it is saved.
  • Thanks for your replay at first.

    1.could you please show me an example how to  extend the controller ?I did it as the sugar document say,but I only find the validation before save.I really hope to know how to run my custom js function when the page is ready,because I think it will make many things more easy.

    2.You are right,it sounds like default value ,but I hope field A will change when field B or C change,and as I say before ,field A should be able to edit.
    If I'm not wrong, A before_save logic only work when I save the record,in other word,I can't get the value of B+C when I edit the record ,  and also I can't edit and save my custom value because the before_save logic

    Looking forward to your reply and thank you again.


Reply
  • Thanks for your replay at first.

    1.could you please show me an example how to  extend the controller ?I did it as the sugar document say,but I only find the validation before save.I really hope to know how to run my custom js function when the page is ready,because I think it will make many things more easy.

    2.You are right,it sounds like default value ,but I hope field A will change when field B or C change,and as I say before ,field A should be able to edit.
    If I'm not wrong, A before_save logic only work when I save the record,in other word,I can't get the value of B+C when I edit the record ,  and also I can't edit and save my custom value because the before_save logic

    Looking forward to your reply and thank you again.


Children
No Data