Script to parse item description

SOLVED

hi...

trying to create a script that will read a portion of the sales order item description and pull that data into another field.  I can pull the entire description in another field with the script, but my problem is I need to parse part of the description separated by pipe delimiter (|).  The description may look like this: model number = 1234|width=50|hinge side= left active|

I am trying to pull only the part where it starts hinge side.  Here is what I have so far.  It is not working at all, so the syntax must be wrong

slsord = ""

desc = ""

pid6 = ""

item = ""

retVal = oBusObj.GetValue ("SalesOrderNo$", slsord)

retVal = oBusObj.GetValue ("ItemCodeDesc$", desc)

retVal = oBusObj.GetValue ("ItemCode$", item)

If InStr(ItemCodeDesc$,desc},'HINGE SIDE') > 0

Then "HINGE SIDE= " + ExtractString({SO_SalesOrderDetail.desc},"HINGE SIDE=","|")

Else ""

retVal = oBusObj.SetValue("UDF_PID06$", desc)

End if

Thanks for any help...Really appreciate it...

B

  • 0

    Use the Split() function:
    temp = Split(desc,"|")
    For i = 0 to Ubound(temp)-1
    If Instr(temp,"HINGE SIDE") > 0 then
    yada yada...
    Exit For
    End if
    Next

    Note above is untested, you need to check syntax etc.

  • 0
    This line makes no sense: If InStr(ItemCodeDesc$,desc},'HINGE SIDE') > 0
    I think it should be: If InStr(desc,"HINGE SIDE") > 0
  • 0
    This is also not making sense:
    Then "HINGE SIDE= " + ExtractString({SO_SalesOrderDetail.desc},"HINGE SIDE=","|")

    You need a variable after "Then" and "{SO_SalesOrderDetail.desc}" should be "desc".
  • 0 in reply to 49153
    thank you 49153...you're always a big help... I don't get an error this time, but the end result is not working...nothing goes into my udf I created. It should bring the words Left Active in my field based on the pipe delimiter...

    slsord = ""
    desc = ""
    pid6 = ""
    item = ""


    retVal = oBusObj.GetValue ("SalesOrderNo$", slsord)
    retVal = oBusObj.GetValue ("ItemCodeDesc$", desc)
    retVal = oBusObj.GetValue ("ItemCode$", item)

    temp = Split(desc,"|")
    For i = 0 to Ubound(temp)-1

    if InStr(desc,"HINGE SIDE") > 0 then
    desc


    retVal = oBusObj.SetValue("UDF_PID06$", desc)

    Exit For


    End if

    Next
  • 0 in reply to beavis
    Try this:

    if InStr(desc,"HINGE SIDE") > 0 then

    temp2 = Split(temp(i),"=") ' Split "hinge side= left active" into "hinge side" and "left active"
    retVal = oBusObj.SetValue("UDF_PID06$", temp2(1)) ' Should return "left active"

    Exit For
  • 0 in reply to 49153
    well...no errors, but no value shows in my udf... we got the formula from the crystal that was set to parse the field, but now they want to see the values in the respective udf fields... thanks for keep on trying... here is the full script again..

    slsord = ""
    desc = ""
    pid6 = ""
    item = ""


    retVal = oBusObj.GetValue ("SalesOrderNo$", slsord)
    retVal = oBusObj.GetValue ("ItemCodeDesc$", desc)
    retVal = oBusObj.GetValue ("ItemCode$", item)

    temp = Split(desc,"|")
    For i = 0 to Ubound(temp)-1

    if InStr(desc,"HINGE SIDE") > 0 then

    temp2 = Split(temp(i),"=") ' Split "hinge side= left active" into "hinge side" and "left active"
    retVal = oBusObj.SetValue("UDF_PID06$", temp2(1)) ' Should return "left active"




    Exit For


    End if

    Next
  • 0 in reply to beavis
    verified answer
    Change: "if InStr(desc,"HINGE SIDE") > 0 then" to

    if InStr(Ucase(temp(i)),"HINGE SIDE") > 0 then
  • 0 in reply to 49153
    by George...I think he's got it...genius!... thanks for the continued help... you rock!