Understanding the boilerplate
The Foundry boilerplate snippet provides the boilerplate code for a VoltScript integration service in Foundry.
Boilerplate snippet
Explanation
- Options are set in line 1 and 2.
- Dependencies are added in lines 4 and 5.
-
Context is created in line 8 and the data loaded into the
data
string at line 12.- If a JWT Token is passed in the context it will be automatically passed to a new
KeepServer
object.
- If a JWT Token is passed in the context it will be automatically passed to a new
-
The
extractObjects()
method is called at line 13. This instantiates the VoltMXRequest, VoltMXSession, VoltMXResponse and VoltMXResult objects using content from the passed JSON object. Calling this method is extremely important; failure to do so will lead to erractic behavior or failures in your VoltScript code. - Custom code can be entered in the area between the comments, at line 18.
- If an error occurs,
VoltMXResult.setMessage()
is called at line 24, parsing the error using thegetErrorMsg()
function. - The VoltMXResult object is converted to a JSON string and printed out. The VoltScript runtime passes this back to Foundry.