Inserting when form is non-editable

(also posted at mibuso) Hope someone can help with this… I have set the Sales Order form and subform to be editable only when the order is open. To achieve this I call the following SETEDITABLE function IF Status = Status::Open THEN BEGIN CurrForm.EDITABLE := TRUE; CurrForm.SalesLines.EDITABLE := TRUE; END ELSE BEGIN CurrForm.EDITABLE := FALSE; CurrForm.SalesLines.EDITABLE := FALSE; END; I call it from ONAFTERGETRECORD ONOPENFORM Code that releases the orders Code that Re-opens released orders. It works great. BUT when a released order is on the form, pressing F3 to insert a new order has no effect. How can I protect non-open orders from being changed, allow users to see these on the same form AND allow users to insert a new record when they happen to have a released record on display ? NB I don’t really want to have to set each field to editable and non editable. Also don’t want to block it at the ONMODIFY trigger as this really too late. Regards Richard H

Richard, We do the same thing, but had a add a little button with “New” on it at the bottom left of the screen to create a new record when the order was released (and non-editable). Regards Meint

Maybe instead of disabling whole form, you just prevent changes using OnModifyRecord() trigger on form ?

quote:


Originally posted by meintd
Richard, … but had a add a little button with “New” on it at the bottom left of the screen to create a new record when the order was released (and non-editable)…


Thanks Meint Sounds like the answer for me. What code do you put behind the “New” button?

We use this for a quote e.g. CLEAR(SalesHeader); SalesHeader.INIT; SalesHeader.“Document Type” := SalesHeader.“Document Type” :: Quote; SalesHeader.INSERT(TRUE); IF GET(SalesHeader.“Document Type”,SalesHeader.“No.”) THEN; Hope it helps Meint

Hi, I use the same principal, only I have one problem : → I can’t use F3 in the detail screen (purchase lines/sales lines). Has someone a solution for this ? Thanks in advance, Nico

Hi, I use the same principal, only I have one problem : → I can’t use F3 in the detail screen (purchase lines/sales lines). Has someone a solution for this ? Thanks in advance, Nico

Maybe creating a CommandButton on the Lines Subform with functionality similar to the one already on the Main Form will do it? It would do the exact same thing for the Lines as the other one for the Header. You just have to hide it behind the TableBox. But anyway, that’s what you get for trying to fight Navision’s way of working.

Just Write the following code in OnNewRecord trigger.CurrForm.EDITABLE := TRUE; CurrForm.SalesLines.EDITABLE := TRUE; Regards

Just a little comment, IF Status = Status::Open THEN BEGIN CurrForm.EDITABLE := TRUE; CurrForm.SalesLines.EDITABLE := TRUE; END ELSE BEGIN CurrForm.EDITABLE := FALSE; CurrForm.SalesLines.EDITABLE := FALSE; END; why dont you just write: CurrForm.EDITABLE := (Status = Status::Open); CurrForm.SalesLines.EDITABLE := (Status = Status::Open);

quote:


Originally posted by chadharajan
Just Write the following code in OnNewRecord trigger.CurrForm.EDITABLE := TRUE; CurrForm.SalesLines.EDITABLE := TRUE; Regards


This won’t work, I’m afraid…

quote:


Originally posted by nelson
Maybe creating a CommandButton on the Lines Subform with functionality similar to the one already on the Main Form will do it? It would do the exact same thing for the Lines as the other one for the Header. You just have to hide it behind the TableBox. But anyway, that’s what you get for trying to fight Navision’s way of working.


There’s no need to create two buttons. Use a global boolean variable, e.g. LinesActive. In the main forms OnActivate() trigger put LinesActive := FALSE; Similarily in the subforms OnActivate() trigger put LinesActive := TRUE;Your “New” button code could then look like this:IF NOT LinesActive THEN BEGIN // Put Header code here END ELSE BEGIN // Put Line code here END;

OK, Steffen, I didn’t remember Subform controls have an OnActivate trigger. But that means that //Put Line code here will have to be something that calls a function on the Lines Subform object, right?

Right, here’s my third comment to this topic [8D]. A solution might be: 1. In the OnAfterGetCurrRecord() trigger of the main form put:CurrForm.EDITABLE(Status = Status::Open);2. Create a Command Button or Menu Item called “New” 3. In the OnPush() add the following code:CLEAR(Rec); "Document Type" := SalesHeader."Document Type" :: Order; INSERT(TRUE); IF GET("Document Type", "No.") THEN CurrForm."No.".ACTIVATE;That should do it. A few reservations though

Do NOT use F3 as shortcut-key since this will overrule standard Navision behaviour in the lines.-
This solution doesn’t emulate standard Navision behaviour exactly; you risk having a lot of empty orders floating about in the system.- If you want to emulate exact F3 behaviour you have to set each field editable/none-editable

quote:


But that means that //Put Line code here will have to be something that calls a function on the Lines Subform object, right?


Yes, correct Nelson [;)] and I completely agree with your previous comment: “But anyway, that’s what you get for trying to fight Navision’s way of working.”