UIPath Invoke VBScript

Hi All,

I’m trying to invoke a VBScript that’s located in my “Test.vbs” file in the Project Directory that needs to accept a sapfewse.GUISession object as an argument. However, the Invoke VBScript activity will only accept a string arguments. Is there an option to change the variable type? Or is there any other way to run VBScript in UIPath with the flexibility of passing any type of arguments?

Thanks in Advance!
Regards,
Johann.

2 Likes

Hi Johann,

You should try creating a Custom Activity.

https://docs.uipath.com/activities/docs/creating-a-custom-activity

1 Like

Hello @Johann,

in my opinion it is not necessary to transfer the GUISession object to the VBScript directly. You know the session object in your calling program. With the property ID you can get the full ID of the session as string, e.g. like this:

/app/con[0]/ses[1]

Dismantle this string to get the connection number, in this example 0, and the session number, in this example 1. Now you can transfer this numbers to your VBScript and use it like I described here.

A tiny hint: It is not possible to use one SAP session parallel with two or more different SAP GUI Scripting calls. Be sure, before you execute a new SAP GUI Scripting call, that the previous one has ended. Or better is to use the Busy property from the session object.

Best regards
Stefan

3 Likes

Hi Stefan,

Thank you so much for your suggestion and the resource link you provided, its a gold mine of information for what I’ve been trying to achieve.

If I could rack your brain for another problem I’ve been having with SAP GUI Scripting with UIPath? I’m trying to use the “Get Text” Activity to get a value from a cell in SAP. The selector for the field is as follows :

“wnd[0]/usr/subSUB_MAIN:/COCKPIT/SAPLDISPLAY46:0389/subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”

However, the “SAPLDISPLAY46:xxxx” part of the selector seems to change randomly from time to time and the activity seems to crash when it cannot find the defined selector. there is no pattern to the change and i was wondering if there’s a possibility of using a wildcard there, if so what is the correct syntax to make this selector dynamic?

I.e :

“wnd[0]/usr/subSUB_MAIN:/COCKPIT/SAPLDISPLAY46:0381/subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”
“wnd[0]/usr/subSUB_MAIN:/COCKPIT/SAPLDISPLAY46:0385/subSUB_SALDO:/COCKPIT/SAPLDISPLAY46:0440/txt/COCKPIT/SDUMMY-SALDO”

Thank you so much for your assistance so far and I hope you can help me with this problem too.

Regards,
Johann.

2 Likes

Hello @Johann,

thanks for your reply.

To solve the problem with the flexible screen number in the ID you can use wildcards. It is described in the documentation here and in the forum here.

Best regards
Stefan

1 Like

Hi Stefan,

I’ve already gone through the documentation and that forum and have tried using the Wildcard in its place, however I still can’t get the selector to work. I tried every possible syntax as well but with no luck. Is there anything else you can think of that would help?

Regards,
Johann.

1 Like

Hello @Johann,

which transaction code do you use?

Best regards
Stefan

Hi Stefan,

This is a T-code called “/Cockpit/1”. its for our workflow solution “Process Director”.

Regards,
Johann.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.