Line discount % field in sales order how to do not edited in business central

HI ,

any idea please

You have to create an extension.

If you don’t want to apply any line discount %, you can create a table extension:

tableextension 50100 "My Sales Line" extends "Sales Line"
{
    fields
    {
        modify("Line Discount %")
        {
            trigger OnBeforeValidate()
            begin
                if "Line Discount %" <> 0 then
                    Error('"%1" is not editable.', FieldCaption("Line Discount %"));
            end;
        }
    }
}

This way it will fail if some discount is applied manually or automatically, for instance, if the system tries to apply a configured discount in the prices. You can use the event OnValidateLineDiscountPercentOnAfterTestStatusOpen instead de table extension to do the same check.

If you don’t want that nobody change this value manually, you must do some page extensions:

pageextension 50100 "My Sales Inv. Subform" extends "Sales Invoice Subform"
{
    layout
    {
        modify("Line Discount %")
        {
            Editable = false;
        }
    }
}

You must create a page extension for each page that goes on “Sales Line” table and put the field as not editable.

Hi Pjlaneras

Thank you very much

But we need something more

how can do for some users to edit line discount and some other user no edit the field ?

Regards ,

Erald

Hello @ERI,

I would create a boolean field (table extension) in the “User Settings” table, and allow users with this new field to edit the discount field, this would be possible with page extensions, doing a bit of programming in the trigger OnOpenPage, and the Editable has to be a variable.

Hello ,

If you can do it please let me know

Regards ,
Erald

I think from what you’re asking, you’re not working at a Microsoft partner and you’re not an AL developer… ask your Microsoft partner this. This forum is to resolve doubts, not to carry out this type of work.