Scripting

  • 1.  Hi All,Working on a simple script in Purchase or

    Posted 05-22-2015 07:58
      |   view attached
    Hi All, Working on a simple script in Purchase order. I have added a checkbox UDF to the Purchase order header called StockOrder. I then added it to the customizer so I can see the check box on the Header tab of the Purchase Order Entry screen. Next I wrote a simple script as follows: sCheckbox = """" retval = oScript.DebugPrint(""You just changed the check box value on the header"") retval = oBusObj.GetValue(""UDF_STOCKORDER$"",sCheckbox) retval = oscript.debugprint(""Header Checkbox value is now "" & sCheckbox) Then I assign it to the Po Purchase Order Header on the Column-PreValidate event and the field is the UDF_STOCKORDER. So basically when that field is changed, write the value to the debugger screen. This works properly. in the debug screen i'll see it tell me the value is now Y or N as I check and uncheck it. So far so good right? next I create another script as follows: retval = oScript.DebugPrint(""START Detail value of check box Script"") retval = oScript.debugprint(""A new detail was just entered lets check the value of the StockOrder Header Checkbox . . ."") sCheckbox = """" retval = oBusObj.GetValue(""UDF_STOCKORDER$"",sCheckbox) retval = oscript.debugprint(""The detail level sees the StockCheckBox value as **"" & sCheckbox & ""**"") retval = oScript.DebugPrint(""END Detail value of check box Script"") Again pretty basic. I assign this one to the PO Purchase Order Detail table on the Column-prevalidate event. I attached it to the ExtensionAmt field (I key in the extension amount$ it wouldn't have to be this field, but just any field I can make a change to to fire the code basically ) So when I enter a new line before it moves to the next new line the script fires. My problem is that I can never get the checkbox value when i'm at the line level. I am able to get it in sales order in this manner, but on the po screens no luck. Is there something special about the PO screens? how do I pass a header value to the line level in the PO screen? Please see attached debug screen that shows me checking the box (and returning a Y value) at the header level, then adding a new row in the PO details and the value is blank. thank you, marc

    Attachment(s)

    docx
    ScriptDebug.docx   33 KB 1 version


  • 2.  RE: Hi All,Working on a simple script in Purchase or

    Posted 05-22-2015 08:12
    Oh brother - makes sense after I see it - i need to oHeaderObj.getvalue! Changing the line to be retval =oHeaderObj.GetValue(""UDF_STOCKORDER$"",sCheckbox) solved it. here is the final detail code: retval = oScript.DebugPrint(""START Detail value of check box Script"") retval = oScript.debugprint(""A new detail was just entered lets check the value of the StockOrder Header Checkbox . . ."") sCheckbox = """" retval =oHeaderObj.GetValue(""UDF_STOCKORDER$"",sCheckbox) retval = oscript.debugprint(""The detail level sees the StockCheckBox value as **"" & sCheckbox & ""**"") retval = oScript.DebugPrint(""END Detail value of check box Script"")


  • 3.  RE: Hi All,Working on a simple script in Purchase or

    Posted 05-23-2015 00:42
    My first programming instructor told us about the 20/80 rule (more like a Murphys Law) which still holds true today. You'll spend 20% of the time coding 80% of the project and 80% of the time debugging the last 20% of the project.


  • 4.  RE: Hi All,Working on a simple script in Purchase or

    Posted 05-23-2015 00:55
    I love all your DebugPrint's. This is great practice for the zany scripts that involve multiple objects and alternate keys and browse filters and such. Well done Marc.