Calling fieldlookup.js set_multivalues() from lookup forms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling fieldlookup.js set_multivalues() from lookup forms

Daniel Watford
Hello,

I'd like to make use of the set_multivalues() function in fieldlookup.js
from a lookup form to be able to populate multiple fields on a form in a
postal address lookup.

As far as I can tell from reading the function the intent is that the first
argument is the value to set on the primary lookup field, the subsequent
arguments are sequences of input element name and value.

There seems to be some problems with how the target values are set on the
obj_caller object, but I'm not sure I understand enough of what's
happening and the intention to start changing things.

To demonstrate the issue, in an Ofbiz environment with multiple facilities,
temporarily modify line 51 in
applications/product/widget/facility/FieldLookupForms.xml from:

<hyperlink description="${facilityId}"
target="javascript:set_values('${facilityId}', '${facilityName}')"
also-hidden="false" target-type="plain"/>

to:

<hyperlink description="${facilityId}"
target="javascript:set_multivalues('${facilityId}', 'infoUrl',
'${facilityName}')" also-hidden="false" target-type="plain"/>

The idea of the above is that we will write the facility name to the
infoUrl input on the form calling for the lookup.

Steps:
- visit https://localhost:8443/workeffort/control/FindWorkEffort
- click on the Create Work Effort button
- click on the lookup button for the Facility ID field.
- click the Find button to list all facilities.
- click on the ID button (left-most button) for once of the found
facilities.

Observe in the Dev Tools console that errors occur due to obj_caller.target
being null in the set_multivalues() function.

I did play around with the function to set obj_caller.target from

obj_caller.target = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).target

but then ran into problems regarding looking up the form from the target
and evaluating statements addressing the targetting fields.

Any advice on how to fix, or whether set_multivalues() was not intended for
this use case gratefully received.

Thanks,

Dan.

--
Daniel Watford
Reply | Threaded
Open this post in threaded view
|

Re: Calling fieldlookup.js set_multivalues() from lookup forms

Daniel Watford
OFBIZ-11274 created to address this with patch attached.

On Sun, 3 Nov 2019 at 20:38, Daniel Watford <[hidden email]> wrote:

> Hello,
>
> I'd like to make use of the set_multivalues() function in fieldlookup.js
> from a lookup form to be able to populate multiple fields on a form in a
> postal address lookup.
>
> As far as I can tell from reading the function the intent is that the
> first argument is the value to set on the primary lookup field, the
> subsequent arguments are sequences of input element name and value.
>
> There seems to be some problems with how the target values are set on the
> obj_caller object, but I'm not sure I understand enough of what's
> happening and the intention to start changing things.
>
> To demonstrate the issue, in an Ofbiz environment with multiple
> facilities, temporarily modify line 51 in
> applications/product/widget/facility/FieldLookupForms.xml from:
>
> <hyperlink description="${facilityId}" target="javascript:set_values('${facilityId}', '${facilityName}')" also-hidden="false" target-type="plain"/>
>
> to:
>
> <hyperlink description="${facilityId}" target="javascript:set_multivalues('${facilityId}', 'infoUrl', '${facilityName}')" also-hidden="false" target-type="plain"/>
>
> The idea of the above is that we will write the facility name to the
> infoUrl input on the form calling for the lookup.
>
> Steps:
> - visit https://localhost:8443/workeffort/control/FindWorkEffort
> - click on the Create Work Effort button
> - click on the lookup button for the Facility ID field.
> - click the Find button to list all facilities.
> - click on the ID button (left-most button) for once of the found
> facilities.
>
> Observe in the Dev Tools console that errors occur due
> to obj_caller.target being null in the set_multivalues() function.
>
> I did play around with the function to set obj_caller.target from
>
> obj_caller.target = GLOBAL_LOOKUP_REF.getReference(ACTIVATED_LOOKUP).target
>
> but then ran into problems regarding looking up the form from the target
> and evaluating statements addressing the targetting fields.
>
> Any advice on how to fix, or whether set_multivalues() was not intended
> for this use case gratefully received.
>
> Thanks,
>
> Dan.
>
> --
> Daniel Watford
>


--
Daniel Watford