Scripting

  • 1.  @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-23-2015 10:28
      |   view attached
    @Sage100Routine This is from @MarcCregan Hi there, I am trying to validate a customer UDF when moving from the lines tab to the totals tab in Sales Order. I have setup a checkbox udf on the customer (UDF_PolandCheckBox). I am basing my script on the 'So_Header_Line_Discount.txt' script we did in the scripting class prior to Meeting of the Minds this year. This script added up the detail lines, then calculated a discount amount if the order was over 1000.00. I am trying to do something similar, but only add in the new line and amount if the customer UDF checkbox is checked. First question is how do I pull in the customer UDF value to the script? I tried retval = oBusObj.getvalue(""UDF_POLANDCHECKBOX$"",nPVATValue) but always get a return value of 0. Second question is what is the normal return value of a check box? Is it Yes/No, 0/1 or some other value? Should my variable be a string, numeric or Boolean? The blue highlighted lines below are my attempt at solving this, but don't return anything but 0. Attached is my slightly modified script.

    Attachment(s)

    pdf
    Script.pdf   119 KB 1 version


  • 2.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-23-2015 10:35
    @MarcCregan - Very simple (maybe stupid) question - Is the UDF (Poland) in the customer master and are you pulling that value to the SO header UDF when you populate the SO order with the customer number? If you aren't populating that way, I would suggest you remap the SO UDF to pull the value from the customer master. Leave the population code out of the script entirely. Regarding the value. When you set up the udf in customer master, you can set the default value to Y/N. If you don't, I believe a Null is the default. This will change when you turn it on in the customer master or subsequently turn it off.


  • 3.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-23-2015 11:28
    @MarcCregan the check box is a string with either 'Y' or 'N'.


  • 4.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-23-2015 11:42
    or blank.


  • 5.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-23-2015 12:13
    Since the UDF is a string then you must initialize your UDF to a string value (like """") BEFORE the GetValue. Also, nPVATValue beginning with an 'n' would imply that it is a numeric. An 's' would indicate that it is a string.


  • 6.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-23-2015 12:34
    Hi all - Thank you all for your insight. First problem was as @JeffSchwenk mentioned I didn't have the UDF in the SO header. Knowing the return values really helps @RobertWood ! @DanBurleson I'll change the variable notation to a string and initialize properly too. Its making sense why I was getting wonky returns now! Thanks guys!


  • 7.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-23-2015 12:48
    If it is any consolation, you are way ahead of me on this stuff @MarcCregan


  • 8.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-27-2015 11:49
    Hi there - Progress! Ok With all your help I am now able to calculate a total and validate against a UDF. Next question - Related to working with lines in a grid. I initialize the oLines variable as a OBusObj.Lines object. Where can I find all of the properties/methods for the .lines object?(or any other objects for that matter) Like can I explicity tell it to goto line 3, or can I insert a new line between existing lines instead of at the end? Or can you script-matically tell it to move the current line up one? Thank you!


  • 9.  RE: @Sage100Routine This is from @MarcCregan Hi th

    Posted 04-27-2015 13:04
    Found it - the answer is on page 3 of the ScriptingPlus document: retVal = oBusObj.InsertLine(LineSeqNo) Positionally inserts a line (just like clicking the Insert Lines button on the Lines tab). Prior to this, do a GetValue() on the LineSeqNo column. Ex: strLineSeqNo = """" retVal= oLines.GetValue(""LineSeqNo$"", strLineSeqNo) retVal= oLines.InsertLine(strLineSeqNo)