Scripting with custom tokens

Jason_Webster's picture

I am trying to set a custom token as a variable in a vbscript.

I set up the custom data source in the tools menu.

The line is:

strVariable = %#DB-Alias*"Select Field1 from Table where Field2 = whatever"%

I've also tried:

strVariable = "%#DB-Alias*"Select Field1 from Table where Field2 = whatever"%"

DB-Alias is the name I set up in custom data sources.

Either way it sets strVariable to null.

I'm not sure what I'm missing, any help would be appreciatted.

Thanks.

eorme's picture

Custom tokens

Try this format.  I use custom tokens all the time and haven't had any trouble.

%#*"select data from dbo.myCustomTable where id='123'"%

meson3902's picture

Custom tokens

Your solution unfortunately doesn't cover the two issues:

  1. A custom database
  2. Looking up a value based on a dynamic parameter.

I am encountering the same issue when I try to look up information based on a computer's serial number.

ssilvest's picture

Does your token work if you

Does your token work if you use it in a DOS task? You can do it direct from DS instead of a batch file.
i.e. echo %#DB-Alias*"Select Field1 from Table where Field2 = whatever"%

Also, you may need to put inverted commas around 'whatever', in your query.