Scripting

  • 1.  Hi all - I can provide the actual script code if n

    Posted 07-21-2017 12:09
    Hi all - I can provide the actual script code if needed, but this is almost a request for more general information too. I have one script that calculates and displays the Qty Available on the Sales Order Line and I had to convert the numeric result to CStr in order to make sure the negative sign showed in the UDF field for a negative value. I have a secondary script that runs to recalculate the Line's Promise Date based on conditions involving the Qty Available UDF, Qty Ordered and linked Primary Vendor Lead Time. It works great for a Qty Available of 0 or more, but it will not work for negative available quantities. I've tried CInt(sQtyAvailable) < nQtyOrdered, sQtyAvailable < CStr(nQtyOrdered), CDbl(CInt(sQtyAvailable)) < nQtyOrdered, etc. Why am I having such a problem? It shouldn't be this hard. Any advice?


  • 2.  RE: Hi all - I can provide the actual script code if n

    Posted 07-21-2017 12:40
    That all sounds reasonable to me, though you may want to watch out for CInt's rounding. In a pinch, you could explicitly look for the negative ( If Left(sQtyAvailable,1)=""-"" then nQtyAvail = CInt(sQtyAvailable)*-1, or something like that).


  • 3.  RE: Hi all - I can provide the actual script code if n

    Posted 07-21-2017 14:01
    If you want to show negative sign without converting to string, in UDF Maintenance on your numeric UDF on the masking put a ""-"" at the beginning or end. So now look for < 0 to identify negative values. Hope that helps.


  • 4.  RE: Hi all - I can provide the actual script code if n

    Posted 07-24-2017 11:32
    Alnoor - that worked exactly the way I needed. Thank you so much! Steve, thanks for your time in replying too!


  • 5.  RE: Hi all - I can provide the actual script code if n

    Posted 07-24-2017 12:15
    I only know that because a while back I got one of those ""hey WTH your UDFs are not showing negative amounts please fix your program"" and then saw with DFDM the negative amounts were there. I think on every new numeric UDF, the system should default it to include the negative sign in the mask and then you decide if you want to remove it.