web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Obtain data from VBS s...
Power Automate
Unanswered

Obtain data from VBS script and pass to variable

(0) ShareShare
ReportReport
Posted on by 17

Good morning,

I'm testing a PAD flow that should run a SAP automation using the Pro-code approach, therefore using SAP VB scripting engine.

The PAD flow obtains dynamics values from a Cloud flow, it runs some PAD conditional logic to pass Input variables to the script.

SAP should run this script with input values to create a new customer record, and the script finally must be able to read from the status notification the newely created customer code.

 

I have one obstacle:

My company policies deny the execution of VisualBasic scripts in our machines, so the 'Run VBScript' action of PAD doesn't work. No problem because I used the walkaround way to dynamically write the VB script code by using 'write in a text file' action of PAD, after that I use the no-code approach of PAD to open SAP, launch the SAP Recording and Scripting feature, and give as input the just created VBS.

 

My problem now is that I have to read the new Customer record code from the SAP status bar, and pass this value to an Output variable of PAD, which will return it to the cloud flow.

I can get the Customer record code, but I cannot assign it to the PAD variable because with the 'write in a text' action the output variable is displayed as follows:

"" = session.findById("wnd[0]/sbar/pane[0]").Text
 
On the other hand, I obtained a single machine without the company policy that locks VB scripts execution, but I'm still in trouble because I have to apply conditional logic on the VBS, and with the 'Run VBScript' action you can input the script lines of code once, no conditional logic within the action itself.
In order to proceed, then I thought to read the content of the VBS file created with 'write in text file' actions that I used earlier, to pass the whole content to the 'Run VBScript' action, but doing in this way I pass a variable that contains the VBS, which in turn contains other variables namely my input data of PAD.
 
The only walkaround that I found is to generate a msgbox() window from the VBS, that include the SAP new customer code, and then from PAD I run the 'extract data from a window' action to pull it into the output variable... not a reliable way to work.

Can you suggest me some ways to assign SAP VBS data to an Output variable from a scenario like this?
 
Thank you in advance
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @mattiabergo 

     

    in the run vbs script action, there is a variable which stores output of vbsscript action ie VbScriptOutput 

     

    Nived_Nambiar_0-1684262135402.png

     

     

    to make SAP VBS data output to this variable (i e the Customer Code), you have to use WScript.Echo function to make the value output to this output variable 

     

    Like , let's say the customer code is stored in variable SAPCustCode, 

     

    Now in the vbscript, at end use 

    WScript.Echo SAPCustCode

     

    Nived_Nambiar_1-1684262367408.png

     

     

    Using above code will result in SAPCustCode stored in the VBScriptOutput variable.

     

     

    Hope it helps !

     

     

     

  • mattiabergo Profile Picture
    17 on at

    Hi Nived,

    In my case I have the following Run VBScript action, which obtains the code to run from a variable, this variable is generated from a 'read from file' action that reads the VBS file.

    In this way, it seems not running the VB script because that action wants the VB code explicitly written into it's body.

    How can I create the SAP VB code dinamically then? this Run VB script action doesn't permitt to concatenate pieces of snippets between then I can use conditional logic.

     

     

  • Verified answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @mattiabergo 

     

    I think it occurs since read from file consider the file content as text so using it under variable will be considered as text only instead of command or codes. 

     

    If you want to run vbsscript as file, run it from command line like below

     

    cscript YourScript.vbs

     

    replace YourScript.vbs with filename you want to run, before running the command, use cd to change the path of execution to the directory where the script is present 

     

    You can use cmd actions for this in power automate .

     

    Also to make vbscript dynamic, you can utilize variables , while writing the code in run vbsscript action, wherever you need dynamic part, you can use variables from power automate desktop , in that way you can make vbs script more dynamic.

     

    Let me know if you have any additional questions

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard