- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 07:53 AM
Hi,
I need to convert catalog variables (application, application process, environment, versions and components) selected by the user into JSON format so that I can use it for deployment in the workflow.
Below is the format:
{
"application": "hello Application",
"applicationProcess": "hello App Process",
"environment": "helloDeploy",
"versions": [{
"version": "1.0",
"component": "helloWorld"
}]
}
Can you assist me in implementing this requirement?
Solved! Go to Solution.
- Labels:
-
Orchestration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:34 AM
Do this
var test = { "application": current.variables.var1 , "applicationProcess":current.variables.var2, "environment":current.variables.var3, "versions": [{ "version": "1.0", "component": "helloWorld" }] }
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:34 AM
Do this
var test = { "application": current.variables.var1 , "applicationProcess":current.variables.var2, "environment":current.variables.var3, "versions": [{ "version": "1.0", "component": "helloWorld" }] }
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 08:59 AM
Hi Sanjiv,
Thanks for responding.
But the JSON objects should be in double quotes whereas quotes can't be given for current.variables.var1 and current.variables.var2. So, does this works?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2018 09:06 AM
Yes. It will. 100%
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2018 12:35 PM
Hi Sanjiv,
It's working perfectly. But I have one question. This is the script I have used in workflow.
var app = current.variables.app_name;
var appprocess = current.variables.app_process_name;
var appenv = current.variables.env;
var JSONver = [];
var JSONcomp = [];
var JSONresponse = JSON.parse(current.variables.storeDetails);
for(var i=0; i<JSONresponse.table.rows.length; i++){
JSONver.push(JSONresponse.table.rows[i].row[1]);
JSONcomp.push(JSONresponse.table.rows[i].row[0]);
workflow.scratchpad.JSONver = JSONver;
workflow.scratchpad.JSONcomp = JSONcomp;
var JSONstring = { "application": '' + app , "applicationProcess": '' +appprocess, "environment" : '' +appenv, "versions": [{ "version": JSONver, "component": JSONcomp }] };
}
var test = JSON.stringify(JSONstring);
gs.log('workflow' + test);
and it's giving me output in the following format:
{"application":"GBD_Demo",
"applicationProcess": "DBmaestro Deployment",
"environment": "QA_Env_1",
"versions":[{
"version":["100.122", "122.34"],
"component":["Database","GBD_Demo"]
}]
}
Whereas I need the output in the following format:
{"application":"GBD_Demo",
"applicationProcess": "DBmaestro Deployment",
"environment": "QA_Env_1",
"versions":[{
"version":"100.122",
"component":"Database",
},
{
"version":"122.34",
"component":"GBD_Demo",
}]
}
Can you please let me know how to achieve the above format?