How to pass a variable value to a execute command vbs .

Post Reply
manu0521
Posts: 81
Joined: Wed Nov 26, 2014 8:32 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2010

How to pass a variable value to a execute command vbs .

Post by manu0521 » Sun Apr 05, 2020 11:48 pm

Hi ,

I have a TI which calls a vb script to send some email .

ExecuteCommand('Cscript.exe D:\VBS\EmailScripts\SendLeaseApprovalRequest.vbs "Lease Approval Request" "Please review the lease that has been submitted" "ABC" "leaseApprover" LeaseIDString ',0);

I have a LeaseIdString which has a value like "98" which is a variable value in ti .

I tried passing the variable name but the output is passing the value itsself as "LeaseIDString"

Thanks,

Wim Gielis
MVP
Posts: 2426
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365 - latest
Location: Brussels, Belgium
Contact:

Re: How to pass a variable value to a execute command vbs .

Post by Wim Gielis » Mon Apr 06, 2020 1:38 am

Assuming your syntax works otherwise:

Code: Select all

 ExecuteCommand('Cscript.exe D:\VBS\EmailScripts\SendLeaseApprovalRequest.vbs "Lease Approval Request" "Please review the lease that has been submitted" "ABC" "leaseApprover" ' | NumberToString( LeaseIDString), 0);
Best regards,

Wim Gielis

Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 112 TM1 articles and a lot of custom code
Newest blog article: Selecting elements in the Subset Editor quickly

manu0521
Posts: 81
Joined: Wed Nov 26, 2014 8:32 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2010

Re: How to pass a variable value to a execute command vbs .

Post by manu0521 » Tue Apr 14, 2020 6:50 pm

HI Wim,

Sorry to ask you again

I had to modify this to now include a string variable in between and it errors out and i am unable to identify the syntax .

pLeaseSubmitter is a ti string variable .

Execute command(' ',0); I dont know how to pass the pLeaseSubmitter.

ExecuteCommand('Cscript.exe D:\VBS\EmailScripts\SendLeaseApprovalRequest.vbs "Lease Approval Request" "Please review the lease that has been submitted for Approval" pLeaseSubmitter "leaseApprover" ' | NumberToString(CurrentLeaseId), 0);

lotsaram
MVP
Posts: 3386
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: How to pass a variable value to a execute command vbs .

Post by lotsaram » Tue Apr 14, 2020 8:29 pm

Seriously! You did join this forum over 5 years ago. Even if you are just clicking buttons and paying not much attention that is quite a lot of time to learn SOMETHING.

You do know what ExcecuteCommand is doing? You know that you can always AsciiOutput the same string to a text file and then paste it into a cmd window manually to debug what you are doing?? It is pretty obvious you are passing pLeaseSubmitter within single quotes so you are passing the string of the parameter name not the parameter value. That should be more than enough of a hint.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.

manu0521
Posts: 81
Joined: Wed Nov 26, 2014 8:32 pm
OLAP Product: TM1
Version: 9.5
Excel Version: 2010

Re: How to pass a variable value to a execute command vbs .

Post by manu0521 » Wed Apr 15, 2020 2:23 am

Hi ,

Thanks for yor suggestion. I know what Asciioutput does and it accepts only string .

In the above case with executecommand where it has 2 parameters the commandline and wait argument. I was not sure what commandline format should be sent in tm1, looks like its a string with vbs script location and if any parameters that are seperated by space and the whole single quote with script location and parameter was confusing .

I defintely know having a tm1 variable inside a single quote will consider that as a string ,but in this case i was little confused with the other paramerers and script location.

I should have spent little time and tried .I did try this again and got it working .

ExecuteCommand('Cscript.exe D:\VBS\EmailScripts\SendLeaseApprovalRequest.vbs "Lease Approval Request" "Please review the lease that has been submitted for Approval" ' |pLeaseSubmitter |' LeaseApprover ' | NumberToString(CurrentLeaseId), 0);

The above one is working , now the only issue is the pLeaseSubmitter ,if this has a value which includes a space in the variable value , then my arguments that goes to the script changes , so should i still have something like expand function which would encapsulate the value of my pLeaseSubmitter with in double quotes.

Thanks,

lotsaram
MVP
Posts: 3386
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: How to pass a variable value to a execute command vbs .

Post by lotsaram » Wed Apr 15, 2020 6:50 am

manu0521 wrote:
Wed Apr 15, 2020 2:23 am
The above one is working , now the only issue is the pLeaseSubmitter ,if this has a value which includes a space in the variable value , then my arguments that goes to the script changes , so should i still have something like expand function which would encapsulate the value of my pLeaseSubmitter with in double quotes.
You say you know what you are doing, yet it doesn't sound like you do. :roll:
Just include extra double-quotes within the literal string portion of building the command line!

... submitted for Approval" "' |pLeaseSubmitter |'" LeaseApprover ...
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.

Post Reply