Where to set default value on Sales Order Subform?

gadzilla1gadzilla1 Member Posts: 316
Hello all,

I've attempted this a number of different ways with no success...

When a user selects 'Resource' as Type in the Sales Order Subform, I'd like the Quantity for that line and that line only to default to 1.

I don't know if my issue is in syntax or placement...any suggestions/samples would be much appreciated!

I'm a newbie but for every 3, 4 issues I figure out there is one that I get stuck with, and this is one. Thanks! Chris

Answers

  • babbab Member Posts: 65
    Hello,
    you can add code to the "Sales Line" table, to the Type - OnValidate trigger, something like this:
    IF (Type <> xRec.Type) AND (Type = Type::Resource) AND ("Document Type" = "Document Type"::Order) THEN
      VALIDATE(Quantity, 1);
    
  • gadzilla1gadzilla1 Member Posts: 316
    can't i do that somewhere in the Sales Order Subform?
  • SavatageSavatage Member Posts: 7,142
    edited 2007-04-19
    It's better to put your code on the Table instead of the form.

    Is there a reason you prefer the form?
  • David_SingletonDavid_Singleton Member Posts: 5,479
    gadzilla1 wrote:
    can't i do that somewhere in the Sales Order Subform?

    You should never put processing code on a form, always in a table or codeunit.
    David Singleton
  • gadzilla1gadzilla1 Member Posts: 316
    Thank you and thank you!

    In regards to the 'preference' inquiry, no preference, I'm just new. :) Thanks - Chris
  • gadzilla1gadzilla1 Member Posts: 316
    I placed everything where suggested above. When I select 'resource' for the type on the sales order, nothing defaults in Quantity...

    Shouldn't I now see a '1' in the Quantity field? It's still blank...

    I want quantity to be editable, just only to default to '1' when a Type of 'Resource' is selected.

    Suggestions? Thanks - CDM
  • SavatageSavatage Member Posts: 7,142
    Resource is a type - select resource as type & then enter a resource No and it should change.

    I don't use resoucre ever as a type - so I haven't tested it but we do have all our sales lines default to 1 regardless of the type.

    Where are you putting the code & are you making a sales order or a sales invoice?

    Maybe try something like this....

    No. - OnValidate()
    IF Type IN [Type::Item,Type::Resource] THEN
    VALIDATE(Quantityty,1)
    ELSE
    VALIDATE(Quantity);
  • MbadMbad Member Posts: 344
    Savatage is correct. Do it on validating No. somewhere after the init
  • gadzilla1gadzilla1 Member Posts: 316
    This works great, thanks to all!
  • SavatageSavatage Member Posts: 7,142
    Glad to help. Please put [Solved] in the post title
  • gadzilla1gadzilla1 Member Posts: 316
    Glad to...thanks again. What is the proper way to do that?
Sign In or Register to comment.