cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass variable with value from one script unit to another script unit within a Project

SOLVED
Highlighted
New Contributor

How to pass variable with value from one script unit to another script unit within a Project

Hi,



I am trying to pass variable from one script to another script within a Project.



I have added a Department in Add_Department Script Unit. The added value stored in a variable. In Edit_Department Script unit we need that added Department value.



Seems like after running Add_Department script, if we pass the added department value in Edit Department it is retriving the passed value.



Anyone please help on this.





Regards

Chitra.
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Valued Contributor

RE: How to pass variable with value from one script unit to another script unit within a Project

Check this article:

http://support.smartbear.com/viewarticle/56539

''-Praise the sun and Give Kudos.''

View solution in original post

3 REPLIES 3
Highlighted
Valued Contributor

RE: How to pass variable with value from one script unit to another script unit within a Project

Check this article:

http://support.smartbear.com/viewarticle/56539

''-Praise the sun and Give Kudos.''

View solution in original post

Highlighted
New Contributor

RE: How to pass variable with value from one script unit to another script unit within a Project

Hi,



Thanks for the reply. We followed the same with the link you have given. But it is not working.



without running the whole Add_Department function, how can we call the variable and the stored value directly to Edit_Department. script Unit.



Regards

Chitra.C
Highlighted
Valued Contributor

RE: How to pass variable with value from one script unit to another script unit within a Project

You must declare the variable outside the function for it to be a "global" variable, and also have the USEUNIT <scriptnamewithglobalvariable> added to scripts that need to acccess the global variable. Additionally you can use project variables.



JScript Example:



UNIT1:



//USEUNIT UNIT2

function main(){

wshell.popup(myGlobalVariable);

myGlobalVariable = 'test2';

secondary();

wshell.popup(myGlobalVariable);

}





UNIT2:



wshell = new ActiveXObject('WScript.Shell');

myGlobalVariable = 'test1';



function secondary(){

wshell.popup(myGlobalVariable);

myGlobalVariable = 'test3';

}


''-Praise the sun and Give Kudos.''
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors