Scripting

  • 1.  I'm attempting to get the discount amount values i

    Posted 04-21-2017 06:38
    I'm attempting to get the discount amount values in SO sales order entry from the record in im_pricecode for the current line. I'm looking for an easier way to figure out which price code record sage used to determine the unit price. I may resort to just using the svc object and multiple Find attempts to locate the correct record but was hoping the below method would do what I need it to. I'm trying to use the GetPriceMethod in SO_SalesOrderDetail_Bus inherited from IM_PriceCode_svc. From the help files it has these arguments, FUNCTION GetPriceRecord(prcCode$, item$, priceLevel$, divNo$, custNo$, priceRecord$, priceIOL$, priceType$) I've tried the following, LET prcCode$ = """", item$ = """", priceLevel$ = """", divNo$ = """", custNo$ = """", priceRecord$ = """", priceIOL$ = """", priceType$ = """"; LET prcCode$ = ""STD"", item$ = ""BOARD-04500"", priceLevel$ = ""A"", divNo$ = ""00"", custNo$ = ""CARTER"", priceRecord$ = ""2"", priceIOL$ = CPL(""Iolist PriceCodeRecord$, PriceCode$, ItemCode$, CustomerPriceLevel$, ARDivisionNo$, CustomerNo$, PricingMethod$, DiscountMarkup1""), priceType$ = ""2""; msgbox (STR(coHeader'Lines'GetPriceRecord(prcCode$, item$, priceLevel$, divNo$, custNo$, priceRecord$, priceIOL$, priceType$))),ERR=*NEXT and LET prcCode$ = """", item$ = """", priceLevel$ = """", divNo$ = """", custNo$ = """", priceRecord$ = """", priceIOL$ = """", priceType$ = """"; LET prcCode$ = ""STD"", item$ = ""BOARD-04500"", priceLevel$ = ""A"", divNo$ = ""00"", custNo$ = ""CARTER"", priceRecord$ = ""2"", priceIOL$ = """", priceType$ = ""2""; msgbox (STR(coHeader'Lines'GetPriceRecord(prcCode$, item$, priceLevel$, divNo$, custNo$, priceRecord$, priceIOL$, priceType$))),ERR=*NEXT No dice with either, if I don't use ""ERR=*NEXT"", I get an error about the arguments don't match what's specified Anybody familiar with this method and the proper way to use it? Also, the above syntax is providex but I can use vbscript or providex.


  • 2.  RE: I'm attempting to get the discount amount values i

    Posted 04-21-2017 09:49
    Sorry, I've never used it. I would probably brute force it thru IM_PriceCode, but I'm a sucker for unnecessarily re-inventing the wheel....


  • 3.  RE: I'm attempting to get the discount amount values i

    Posted 04-21-2017 10:03
    LoL, I've unnecessarily re-invented the wheel once or twice due to ignorance. I'm trying really hard to avoid such scenarios going forward.


  • 4.  RE: I'm attempting to get the discount amount values i

    Posted 04-21-2017 10:19
    Also, what's really frustrating is the inconsistency in the help files for the business objects, some have details that tell you which arguments are input vs output. Others just list the method name without indicating it requires arguments. Granted, so far, the ones I've encountered like this are usually inherited and if you look at the object is was inherited from, it usually has the arguments listed.


  • 5.  RE: I'm attempting to get the discount amount values i

    Posted 04-23-2017 19:38
    You got an Error 36 because you diligently passed all the arguments. Not your fault. Had you passed no arguments you would've seen the correct error is 88. SO_SalesOrderDetail_bus inherits from SO_CommonEntryDetail which has GetPriceRecord() but is defined as a private function (FUNCTION LOCAL if you're looking at code). Therefore GetPriceRecord() is invisible to scripting , BOI, and even when you drop to Providex console. So the way to use a private function is: 1) Use a different existing method that is defined as a normal public function (just FUNCTION if you're looking at code) that references GetPriceRecord() 2) Create your own ProvideX class with your own public function that references GetPriceRecord(). Your code then create an object handle out of your class. In your case, I say be smart and just get an object handle out of IM_PriceCode_svc. In here GetPriceRecord() is public. On how to pass the arguments it looks like the last 3 arguments are incoming variables. I agree the help is missing a lot. It could be something like this and I'll let you change this to VB Script: oPrice = NEW(""IM_PriceCode_svc"", coSession) ! VBScript --> Set oPrice = oSession.AsObject(oSession.GetObject(""IM_PriceCode_svc"")) retVal = oPrice'GetPriceRecord(""STD"", Item$, ""A"", ""00"", ""CARTER"", PriceRecord$, PriceIOL$, PriceType$) If you're looking for the data in the record then PriceRecord$ has that but is in compiled IOList format so then: SUB(PriceRecord$, SEP, "","") ! For a comma sep list that you can parse but be careful with commas ! For VBScript --> Replace(PriceRecord, CHR(138), "","") Lastly but most importantly is what @SteveIwanowski said which is don't recreate the wheel (and we've all done that actually) unless you really really have to.


  • 6.  RE: I'm attempting to get the discount amount values i

    Posted 04-24-2017 09:21
    Thanks @AlnoorCassim . I think I can work with getting a handle to IM_PriceCode_svc, using GetPriceRecord does put me on the correct record. So it seems a little more efficient compared to multiple Find()s or GetResultSets().