Inserting Sales Order when form + subform non-editable

Richard_HensbyRichard_Hensby Member Posts: 10
edited 2004-06-21 in Navision Attain
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.
Richard Hensby
Application Specialist
Infinity Solutions

Comments

  • RobertMoRobertMo Member Posts: 484
    Maybe instead of disabling whole form, you just prevent changes using OnModifyRecord() trigger on form ?
               ®obi           
    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  • Tommy_SchouTommy_Schou Member Posts: 117
    Good suggestion Robert! :)

    Another method (not quite "standard") would be to create a new menu-item on the main form which creates a new record in the table and the put the short-cut key F3 to that menu-item!
    Best regards
    Tommy
  • Richard_HensbyRichard_Hensby Member Posts: 10
    Good suggestion Robert! :)

    Another method (not quite "standard") would be to create a new menu-item on the main form which creates a new record in the table and the put the short-cut key F3 to that menu-item!

    Thanks Tommy, I like this.

    What code do I need to put behind the menu-item to create a new record and display it on the form.
    Richard Hensby
    Application Specialist
    Infinity Solutions
  • Dean_AxonDean_Axon Member Posts: 193
    IF Status = Status::Open THEN BEGIN
    CurrForm.EDITABLE := TRUE;
    CurrForm.SalesLines.EDITABLE := TRUE;
    END ELSE BEGIN
    CurrForm.EDITABLE := FALSE;
    CurrForm.SalesLines.EDITABLE := FALSE;
    END;

    Maybe I am missing something, but reading your code it looks like you are stopping the used from making any amendments to the sales header and line forms ???

    Standard attain (AKA MBS- Navision Edition) functionality stop this from happening anyway ??? If I remember right, the user gets an error message about the order not being open and no modifications can be made ????

    Is this not the same end result ?
    Remember: Keep it simple
  • Richard_HensbyRichard_Hensby Member Posts: 10
    Dean Axon wrote:

    If I remember right, the user gets an error message about the order not being open and no modifications can be made ????

    Is this not the same end result ?

    This only happens for certain fields and actions.

    The requirement that my customer has is for the whole order header and order lines to be non-editable once released. So the code I have implemented achieves this but leaves them without the ability to hit F3 to insert a record.

    Now all I need to know is what code F3 executes so that I can put it behind a new button.
    Richard Hensby
    Application Specialist
    Infinity Solutions
  • Richard_HensbyRichard_Hensby Member Posts: 10
    I have added a button called New Order.
    Behind it I have the code

    CLEAR(rec);
    rec.INIT;

    This seems to mimic the F3 to insert new record logic.

    Anyone see any problems with this code?

    Regards
    Richard Hensby
    Application Specialist
    Infinity Solutions
  • Joachim_SchäfferJoachim_Schäffer Member Posts: 1
    To insert a new order when a released order is on the form, you must make an function and assign her F3.

    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.
  • Richard_HensbyRichard_Hensby Member Posts: 10
    To insert a new order when a released order is on the form, you must make an function and assign her F3.


    How do I assign F3 to a function?

    Regards
    Richard Hensby
    Application Specialist
    Infinity Solutions
  • Tommy_SchouTommy_Schou Member Posts: 117
    How do I assign F3 to a function?

    You create a new menu-item. Put F3 on the item as a short-cut and then you put something like this on the "OnPush"-trigger of the menu-item:
    CLEAR(Rec);;
    INIT;
    "Document Type" := "Document Type"::Order;
    INSERT(TRUE);
    CurrForm.EDITABLE := TRUE;
    

    That should do it.
    Best regards
    Tommy
Sign In or Register to comment.