Script to trigger from VI - Problem with Exit Sub function

SOLVED

Hello,

I have been working on a script that launches after a visual integrator job and have run into an issue with the Exit Sub function. I have seen other threads about how you have to define the Sub first when triggering like this but can't quite figure out how to write that into the script. Or another option is to rewrite the script to get rid of the Exit Sub but I wasn't quite sure how to rewrite this one to exclude it. The error I get when triggering from VI is on the Exit Sub function. The script works fine when done as a BOI script. This is on the Sales Order History Detail table. Thanks for any help!

curtrack = ""
alltrack = ""
x = 0
newtrack = ""

retVal = oBusObj.GetValue("UDF_CURTRACK$", curtrack)
retVal = oBusObj.GetValue("UDF_ALLTRACK$", alltrack)

x = InStr(alltrack,curtrack)

If x <> 0 then
Exit Sub
End if

newtrack = alltrack + " , " + curtrack

retVal = oBusObj.SetValue("UDF_ALLTRACK$", newtrack)

Parents
  • +1
    verified answer

    Call MyScript()

     

    Sub MyScript()

     

    ' script code… now possibly including an "exit sub" command

     

    End sub

  • 0 in reply to Kevin M

    Thanks this did work to fix the error I was seeing. My script still isn't working but I did get past that first hurdle with your help. Do you know of any resources I can use for doing UI scripting? I have really only done BOI scripting which triggers from a Sage event so I am not as familiar with how to write without the oBusObj. That is the error I am now getting when trying to run the VI script and when I try to run this script from a button it just doesn't do anything. I assume that I have not written the field value retrieval correctly which is why the script isn't working. Any direction you can give me would be much appreciated!

  • 0 in reply to Jesse B

    For a button script, to access business objects on an Advanced / Premium system, you need to run the script from the server (option where you configure the button script).

    What are you trying to accomplish?

  • 0 in reply to Kevin M

    Ultimately, I would like to have this script run after using a VI import into Sales Order History Detail to add tracking numbers to a UDF. There is a current tracking string field and an all tracking string field as each line item may have more than one tracking number. The all track will accumulate all the current tracking numbers after import by looking in the string, if current tracking exists already in the all tracking field it exits the script, if it doesn't it adds it on to the end of the script. I got the script to work testing in Sales Order Entry but it needs to be run in History as sometimes the orders will already be invoiced when additional tracking numbers come in. I have tried running it every way I can think of at this point and may be a little turned around from focusing on it so long. I have done several BOI scripts but have not ventured into any UI scripts yet so this is new territory for me. Thank you!

  • 0 in reply to Kevin M

    I think maybe all the issues are related to trying to write into a history file vs an open file. I worked with the person looking for the script and she agreed to have it write into the open purchase order file instead and the script works after running VI now, even without the extra call sub function. Thanks so much for showing me that bit of scripting though. I learn so much from this community!

Reply
  • 0 in reply to Kevin M

    I think maybe all the issues are related to trying to write into a history file vs an open file. I worked with the person looking for the script and she agreed to have it write into the open purchase order file instead and the script works after running VI now, even without the extra call sub function. Thanks so much for showing me that bit of scripting though. I learn so much from this community!

Children
No Data