Hello Ernest,
If I understand correctly, you want to build a form with 2 dependent
selectors : you want to update the second selector option list whenever
the user changes the first selector's value.
You can achieve this with OFBiz by adding a few parameters in your
screen's context, and a specific JavaScript file
(common-theme/template/includes/SetDependentDropdownValuesJs.ftl) that
will trigger an AJAX request when the first selector changes, and update
the second selector's option list using the AJAX request response. You
can find an example for this behavior in
/ofbiz-framework/applications/commonext/widget/ofbizsetup/ProfileScreens.xml
:
[...]
<widgets>
<section>
<condition>
<if-empty field="parties"/>
</condition>
<actions>
* <!-- fields for
SetDependentDropdownValuesJs.ftl -->
<set
field="dependentForm" value="NewUser"/>
<set field="paramKey"
value="countryGeoId"/>
<set field="mainId"
value="USER_COUNTRY"/>
<set field="dependentId"
value="USER_STATE"/>
<set field="requestName"
value="getAssociatedStateList"/> <!-- endpoint that will return values
for the second selector -->
<set
field="responseName" value="stateList"/>
<set
field="dependentKeyName" value="geoId"/>
<set field="descName"
value="geoName"/>
<set
field="selectedDependentOption" value="_none_"/>*
</actions>
<widgets>
*<platform-specific><html><html-template
location="component://common-theme/template/includes/SetDependentDropdownValuesJs.ftl"/></html></platform-specific>*
<screenlet
title="${uiLabelMap.PartyCreateNewCustomer}">
<include-form
name="NewCustomer"
location="component://commonext/widget/ofbizsetup/SetupForms.xml"/> <!--
form with dependent selectors -->
</screenlet>
</widgets>
<fail-widgets>
<include-screen
name="viewprofile"/>
</fail-widgets>
</section>
</widgets>
[...]
Hope it helps !
Florian
Le 23/11/2023 à 08:42, Ernest Hocking a écrit :
Good afternoon everyone
In a form such as Edit product with a field like "productTypeId" the value
in the field is queried from the database e.g. GOOD, This value is
accessible within the form.xml by using "product.productTypeId" from within
a groovy script
My question is: If I change the field value to "DIGITAL_GOOD" how can I
access this changed value to use it in for example another field's drop
down list to make it context sensitive (ie the second field drop down is
dependent on the changed value in the first field) . At present I need to
first update the record
I''ve done a search through the code and tried using parameters.name,
env.name, result,name,context.name but with no success
Any help/suggestions on how to do this sort of context sensitive drop down
would be appreciated.
thanks and kind regards in advance
Ernest