Odyn
October 22, 2020, 8:14am
1
Hello
I am trying to build Connect Web Template application using Connect HTTP Input processess inside workflow and also Jquery/Ajax calls on the frontend.
Inside workflow I have 2 processess:
REVIEW
REVIEWDATA
I have following JSON produced by REVIEWDATA process and stored inside %9 variable
[{“ID”:“8”,“SomeNumber”:“1234”}]
Inside my template I would like to get value of this JSON fields.
Using standard script, trying to do it in this way:
var jobObj = {};
if(automation.jobInfos.JobInfo9){
jobObj = JSON.parse(automation.jobInfos.JobInfo9);
}
// Update static information in the web page
query(“#myReviewID ”).text(jobObj.ID);
Unfortunatelly it seems to be undefined.
Could You please tell me how to extract this back into template?
Phil
October 22, 2020, 9:19am
2
If you’re using jQuery to make an ajax call to your REVIEWDATA process, then that process should simply return a JSON file. So at the end of your process, add a Create File task that only contains %9 .
Also, make sure that the original input task for that process is set to return mime type application/json .
Finally, if your process is using the HTTP Server Input task, you should consider using the NodeJS Server Input task instead since it is more efficient and more robust.
Odyn
October 22, 2020, 10:10am
3
Thank You
I am already trying to make it work, template dont see my %9 json with some reason.
The %9 is set and I am able to save json value into text file.
When I open application, the %9 seems to be undefined
Phil
October 22, 2020, 11:55am
4
Your template does not need to access %9 .
Your Ajax query will retrieve the entire JSON file created by your Workflow process. So it’s that JSON response you use in your template.
The code in your template would look something like this:
$.ajax(myWorkflowURL,{async:false}).success( data =>
{
jobObj = data;
query("#myReviewID").text(jobObj.ID);
}
);
Odyn
October 23, 2020, 6:46am
5
What is myWorkflowURL? Is that HTTP Input request action? like /home or /review ?
Phil
October 23, 2020, 7:28am
6
Odyn
October 23, 2020, 7:40am
7
Ok got it
Thanks
I was telling about %9 because we are holding JSON inside %9 and later parse that inside template standard script
For example to map some data, but Your solution is also very nice to know.