Skip to Content

Call a Script Within a Script

Nov 01, 2017 at 07:48 PM


avatar image

Does anyone know how to call a JavaScript from within a JavaScript?

I have two scripts in my job, one local and one global. I want the global script to give me a result and populate a target in my database table and I want my local script to take that result and run a SQL query on it. I'm using a From LDAP pass so I cannot just wrap the function call inside another function call. From LDAP passes have a column specifically for the scripts so you can only use one per line.

So again, anyone know how to do this, call a script from inside a script?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Steffi Warnecke
Nov 01, 2017 at 09:56 PM

Hello Brandon,

check the sap script for generating a password. It should include other scripts. I'm not at work right now so I can't check the function to call a script, but it wasn't complicated.




Show 6 Share
10 |10000 characters needed characters left characters exceeded

I wouldn't think it would be complicated but the simple call of the script that I would think would work, isn't working.

var result = externalScript(Par);

That above line is producing an error when I try to use it. :(


Are both scripts linked to the job?


Yes. The only thing I can think of is conflicting scope, i.e. one script is local and the other is global and the local script is trying to call the global script. Maybe they both have to be global or local but you can't have a mix match? I'll find out later today. Need to get into that client's site after getting some other stuff caught up.


Hey Brandon,

today I called a global script within a global script.

Both are of course linked in the job and the call in the first script was just

result = otherglobalscript();

So pretty easy indeed (the called script does not need a parameter, that's why () is empty). So I think you are correct, that it might have an issue with one script being local and one global (even though I'm confused why this would be an issue).





Lol... So, I found out the reason why I was having issues. I was doing a lot of cutting and pasting when I was trying to get this script calling another script to work and the version of the script that's deployed in IDM is called something like, "custom_sap_blah". In my Notepad++ files, the script is called, "z_custom_sap_blah" so when I did what I did, the call to the global script was:

var output = z_custom_sap_blah(Par);

This, of course, will not work. Once I changed the call to the proper name of the script as it's deployed, it worked. Sorry all. A simple typo was the issue and it's my fault. :)


Good that it was just a simple CnP error. I was scared reading the thread as I do script calls all the time. :)

Deva Prakash B Nov 02, 2017 at 12:11 PM

Hi Brandon,

Supposer you are inside script A. call the script as below

function ScriptA(Par)


//Calling script B

//if script b returns any values then user below syntax

var res = scriptB(Par); or UserFunc.scripB(Par)

//if script b doesn't return any values then user below

scriptB(Par); or UserFunc.scripB(Par)




Show 1 Share
10 |10000 characters needed characters left characters exceeded

I tried the:

var res = scriptB(Par);

That is producing an error. Maybe adding the, "UserFunc" in front of the script will make a difference. I will try that and report back. Thanks.