When Lookup then Need Non Editable Field

abhinavmehra
Member Posts: 34
Hello All,
I have My PO screen....
I need when I lookup to Receiving Location my ship to code fied work as Editable & Non Editable condition.
Scenario - I have 2 receiving Location 1) A - Default 2) B - Non-Default
When I choose 1) A - Default then I need Ship to code Editable & Lookup
When I choose 2) B - Non-Default then I need Ship to code field is Non-Editable & No Lookup
I wrote the code
where location is a variable of Location Table
location.SETRANGE(location.Distributor ,TRUE);
location.SETRANGE(location."Company Name" , COMPANYNAME);
IF FORM.RUNMODAL(0,location)= ACTION::LookupOK THEN BEGIN
IF location."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);
VALIDATE("Location Code" ,location.Code);
END;
But it gives the Non-Editable for every Location.....
Please give the suggestion Quickly
Thanks
I have My PO screen....
I need when I lookup to Receiving Location my ship to code fied work as Editable & Non Editable condition.
Scenario - I have 2 receiving Location 1) A - Default 2) B - Non-Default
When I choose 1) A - Default then I need Ship to code Editable & Lookup
When I choose 2) B - Non-Default then I need Ship to code field is Non-Editable & No Lookup
I wrote the code
where location is a variable of Location Table
location.SETRANGE(location.Distributor ,TRUE);
location.SETRANGE(location."Company Name" , COMPANYNAME);
IF FORM.RUNMODAL(0,location)= ACTION::LookupOK THEN BEGIN
IF location."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);
VALIDATE("Location Code" ,location.Code);
END;
But it gives the Non-Editable for every Location.....
Please give the suggestion Quickly
Thanks
0
Comments
-
where did you write this code?
Did you try this code after validate?
IF "Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);
is it working if you close and open the form?0 -
Now i tried this code
I am writing this code in Location Code of PO form in Onlookup trigger.
loc.SETRANGE(loc.Distributor ,TRUE);
loc.SETRANGE(loc."Company Name" , COMPANYNAME);
IF FORM.RUNMODAL(0,loc)= ACTION::LookupOK THEN BEGIN
VALIDATE("Location Code" ,loc.Code);
IF loc."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);
END;
Its working
But when I again select Default its still Non-Editable & lookup in also working in Ship to Code filed. I don't need lookup when i choose B Location.0 -
Use
CurrForm."Shipment Method Code" := NOT loc."Default Warehouse";
inplace of
IF loc."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);0 -
Try this...
IF loc."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE)
else
CurrForm."Shipment Method Code".EDITABLE(TRUE);0 -
mohana_cse06 wrote:Use
CurrForm."Shipment Method Code" := NOT loc."Default Warehouse";
inplace of
IF loc."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);
it will do the same.0 -
mohana_cse06 wrote:mohana_cse06 wrote:Use
CurrForm."Shipment Method Code" := NOT loc."Default Warehouse";
inplace of
IF loc."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);
it will do the same.
CurrForm."Shipment Method Code".EDITABLE := NOT loc."Default Warehouse";0 -
Hey thanks Mohana
Its Working Good....
Now What I'll do for Lookup...??
Becoz if its Non-Editable I also Need No LookUp.0 -
vijay_g wrote:mohana_cse06 wrote:mohana_cse06 wrote:Use
CurrForm."Shipment Method Code" := NOT loc."Default Warehouse";
inplace of
IF loc."Default Warehouse"=FALSE THEN
CurrForm."Shipment Method Code".EDITABLE(FALSE);
it will do the same.
CurrForm."Shipment Method Code".EDITABLE := NOT loc."Default Warehouse";
Offcource..good Catch :thumbsup:0 -
abhinavmehra wrote:Hey thanks Mohana
Its Working Good....
Now What I'll do for Lookup...??
Becoz if its Non-Editable I also Need No LookUp.
loc.get("Location Code");
IF NOT loc."Default Warehouse" THEN
EXIT;
IF FORM.RUNMODAL(0,ShpMetCode)= ACTION::LookupOK THEN
VALIDATE("Shipment Method Code" ,ShpMetCode.Code);
try something like this
loc is Location table
shpmetcode is Shipment Method table0 -
No.... this is going all wrong. Data validation should NEVER be on the form level. The data validation part (getting the code, looking up the value, stuff like that) should be in OnValidate on the table level. Then the layout part (setting the control to editable, bold, colors) can go into OnAfterValidate of the form.
Putting all of this logic on the form is the WRONG thing to do.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions