Can we diable a field when some condition is satisfied?
Suppose i have checked a check box ,now i want some text field to be non- editable.
What can be done for it?
I have the above issue with Currform.Field.Enabled property based on condition. And my code as
IF "Item Type" = "Item Type"::"Filter Plate" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);;
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"Filter Cloth" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Cylinder THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"Power Pack" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Valves THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"PLC Panel" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Frame THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Make.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE)
END ELSE
IF "Item Type" = "Item Type"::Instruments THEN BEGIN
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
END;
Its not working properly when i do enter item type or when i click on next rec view.
Each time I choose the rec from list to card, only when i run it again it works fine.
Is it possible to make work on all cases?
1st: "opening" 7 years old topic is not much optimal... ;-)
2nd: you are showing the code to set the properties, but the problem is "from where you call this code". And you are not mention this...
3rd: what about using Case command instead of the not nice if-then-else-if-then-else chain? ;-)
Another thing: you are setting everywhere FALSE. Where are you enabling them?
One TIP: create function like SetControlEnabled(param), put the code there, and from the Case just call the function with correct parameter. This Copy&Paste code is not good. Do not forget to make the code reusable...
Please, do not do what I said, but think about it. It seems, like you want some fields to disable, and some enable. But everywhere in your code there is parameter FALSE. Where is call with TRUE? You must ENABLE the fields somewhere, else you disable them all when going between records...
Comments
in the OnAfterValidate of the check box
Hope this helps
Do not forget to refresh editable property when record is changed (OnAfterGetCurrRecord).
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Coool
It's working
I have the above issue with Currform.Field.Enabled property based on condition. And my code as
IF "Item Type" = "Item Type"::"Filter Plate" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);;
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"Filter Cloth" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Cylinder THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"Power Pack" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Valves THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::"PLC Panel" THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
END ELSE
IF "Item Type" = "Item Type"::Frame THEN BEGIN
CurrForm."Instrument Type".ENABLED(FALSE);
CurrForm.Range.ENABLED(FALSE);
CurrForm.Body.ENABLED(FALSE);
CurrForm."Process Connection".ENABLED(FALSE);
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Make.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE)
END ELSE
IF "Item Type" = "Item Type"::Instruments THEN BEGIN
CurrForm.Type.ENABLED(FALSE);
CurrForm.Tickness.ENABLED(FALSE);
CurrForm."Discharge Type".ENABLED(FALSE);
CurrForm.Varient.ENABLED(FALSE);
CurrForm.BoreDia.ENABLED(FALSE);
CurrForm.RodDia.ENABLED(FALSE);
CurrForm."Stoke length".ENABLED(FALSE);
CurrForm.Model.ENABLED(FALSE);
CurrForm."BOM Door Cylinder".ENABLED(FALSE);
CurrForm."Plate Shifter".ENABLED(FALSE);
CurrForm."Main Cylinder".ENABLED(FALSE);
CurrForm."Side Cylinder".ENABLED(FALSE);
CurrForm."Valves Type".ENABLED(FALSE);
CurrForm."Valves Category".ENABLED(FALSE);
CurrForm.Size.ENABLED(FALSE);
CurrForm.PLC.ENABLED(FALSE);
CurrForm."OP Panel".ENABLED(FALSE);
CurrForm.MCC.ENABLED(FALSE);
CurrForm.LCS.ENABLED(FALSE);
CurrForm.RLC.ENABLED(FALSE);
CurrForm.Gladding.ENABLED(FALSE);
CurrForm.MoC.ENABLED(FALSE);
CurrForm.Kwatts.ENABLED(FALSE);
CurrForm.Pressure.ENABLED(FALSE);
END;
Its not working properly when i do enter item type or when i click on next rec view.
Each time I choose the rec from list to card, only when i run it again it works fine.
Is it possible to make work on all cases?
Thanks & Regards,
Jaanu
2nd: you are showing the code to set the properties, but the problem is "from where you call this code". And you are not mention this...
3rd: what about using Case command instead of the not nice if-then-else-if-then-else chain? ;-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I Wrote the above code in Item type field OnValidate & also in On AfterGetCurrRecord.
One TIP: create function like SetControlEnabled(param), put the code there, and from the Case just call the function with correct parameter. This Copy&Paste code is not good. Do not forget to make the code reusable...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Ok sir. I will try as you said.
Thanks,
Jaanu
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.