Hi Ernest, I'm not aware of any examples in OFBiz that exactly fit your use case. You may implement a solution using javascript to send your request to the testCalc service and then apply the results to the current form.
An example of executing javascript from clicking a hyperlink can be seen in the Example plugin: https://demo-next.ofbiz.apache.org/example/control/FormWidgetExamples and is defined by the following element in FormWidgetExampleForms.xml: <field name="targetUrlButton" title="${uiLabelMap.SignedInAuthToAnotherDomain}" widget-style="buttontext" tooltip="${uiLabelMap.SignedInAuthToAnotherDomainTooltip}"> <hyperlink also-hidden="false" target-type="plain" description="${uiLabelMap.TargetURL}" target="${targetUrl}"/> </field> Another approach, albeit not one I have experimented with, is the on-event-update-area element. See example https://demo-next.ofbiz.apache.org/example/control/authview/findExampleAjax. In this example, screen ExampleAjaxScreens.xml#AjaxExample is rendered containing screens ListExampleFormOnly and CreateExampleFormOnly. Screen CreateExampleFormOnly includes form ExampleForms.xml#EditExampleBackgroundSubmit. Form EditExampleBackgroundSubmit has an on-event-update-area element directing OFBiz to update the ListExamplesAjax area (i.e. the form on the ListExampleFormOnly screen) when the EditExampleBackgroundSubmit form is submitted. If you trace the network calls in your web browser's development tools, you will see that submitting the EditExampleBackgroundSubmit form does not reload the page. Instead a post request is made to endpoint createExampleAjax to create the new Example record. A post is then made to the ListFormExampleOnly endpoint, retrieving the new contents of the list and displaying on the page. There might be a solution for your use case where your Calculate C button is on a small form adjacent to your Product Measures form. The form containing the button would have on-event-update-area configured to update the Product Measures form following a submit event. Please let us know how you get on. Dan. On Sun, 22 Jan 2023 at 04:19, Ernest Hocking <ernest.hock...@computer.org> wrote: > Hi everyone > > I'd like to use groovy to implement some business logic and call that logic > from a button in a form. > > E.g Add a button on the product measures form to calculate the volume > given a product's dimensions.. I've tried > > <field name="calcTest" title=" " widget-style="buttontext"> > <hyperlink description="Calculate C" target="testCalc" > also-hidden="false"> > <parameter param-name="scale-factror"/> > <!-- e.g add an allowance for packing material --> > </hyperlink> > </field> > I can call/test the service "testCalc" from webtools etc but not use the > button. > > Can anyone point me to an example in the existing code base that I can use > as a reference model. > > thanks in advance > > Ernest > -- Daniel Watford