Hello guys,
I have a question about the lookup fields, let me try to explain:
Two lookup fields: DEPARTMENT and SERVICE.
DEPARTMENT has two options Sales, Photos
SERVICE has 10 options Item1,Item2..., Five items are for SALES and 5 for Photos
SERVICE is filtered by DEPARTMENT, so
if I choose Sales in the first lookup field (DEPARTMENT) the second lookup field (SERVICE) will show only the 5 items for Sales,
if I choose Photos in the first lookup field (DEPARTMENT) the second lookup field (SERVICE) will show only the 5 items for Photos.
I have set the default field to Sales, so when I'm adding a new record the first lookup field (DEPARTMENT) shows Sales automatically.
This works fine, my problem is that the second lookup field (SERVICE) show all the 10 items, unless I click in DEPARTMENT and choose Sales again.
So when adding a new record with a default value in the first lookup field does not work without selecting the same value again. Any workaround for that?
Thank you.
Dependent lookup field with default value
Re: Dependent lookup field with default value
Hi,
You can try this by adding the following to your hooks/TABLENAME-dv.js file:
Assuming the your fieldname is DEPARTMENT and the default value is Sales.
You can try this by adding the following to your hooks/TABLENAME-dv.js file:
Code: Select all
$j(function(){
if (AppGini.current_f1.value == "") {
AppGini.current_DEPARTMENT.value="Sales";
}
});
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Dependent lookup field with default value
Hi pböttcher,
That work very well, I've been struggling with this for a long time.
Thank you very much.
PS. I just have to change "SALES" to "1" as it is a lookup field.
That work very well, I've been struggling with this for a long time.
Thank you very much.
PS. I just have to change "SALES" to "1" as it is a lookup field.