V8js Custom Script call another V8js Custom Script?


#1

Hi

I have two custom scripts. I would like to call one custom script (that does a smaller operation) from a larger custom script that does more processing. Would you please help me with the correct syntax?

I have tried:

platform.api.post(“CustomScriptName”, {jsonPayload});

And found this in my logs

Got error 'PHP message: REST Exception #501 > Database or driver does not support fetching all stored procedure names.\nPHP message: REST Exception #501 > Database or driver does not support fetching all stored function names.

I then tried
(guessing based on .js include documentation)

customScript = require(‘CustomScriptName’);

return platform.api.post(customScript, jsonPayload);

But that lead to this error in the logs:

The module “CustomScriptName” could not be found in any known locations.\nPHP message: REST Exception #500 > Module loader callback exception

I have confirmed the custom scripts are both visible on my Services tab and my user’s role has both Script and API access as well as POST access.

Thank you


#2

BTW I am on a Bitnami AWS implementation. Thanks again.


#3

I’m not sure that log error is related to your custom scripts unless you are calling stored procedures in your script.

Not sure if this makes a difference, but if you intend to use the return data from the the smaller operation, you need to assign the api call to a variable so you can work with the return

var smallOperation = platform.api.post("customScriptName",{"json":"object here"});

Then if you want to debug you can return smallOperation to the client to see the output of var_dump(smallOperation) to the log file to see what’s coming back from the other script, including any potential errors.