Prefilling e-Form
Learn how to pass data to e-Form and pre-fill components with data.
Using Form Parameter
Pass values to OZFormParam parameters in e-Form.
Use viewer options connection.pcount and connection.args
customer-formparam.ozr
Open
customer.ozr
and save it ascustomer-formparam.ozr
.Add an OZFormParam name.
Bind the parameter name with the TextBox name.
customer-formparam.html
Open
customer.html
and save it ascustomer-formparam.html
.Pass values for the parameter name and smoker as below:
<script type="text/javascript" >
var name = "John Kim";
var smoker = "Yes";
function SetOZParamters_OZViewer(){
var oz = document.getElementById("OZViewer");
oz.sendToActionScript("connection.servlet", "/training/server");
oz.sendToActionScript("connection.reportname","/forcs/john.kim/customer-formparam.ozr");
// pass values for form parameters
oz.sendToActionScript("connection.pcount", "2"); // the number of paramters
oz.sendToActionScript("connection.args1", "name=" + name); // for the parameter "name"
oz.sendToActionScript("connection.args2", "smoker=" + smoker); // for the parameter "smoker"
}
start_ozjs("OZViewer", "/html5viewer/");
</script>
Using INPUTJSON viewer option
Send a JSON data string to your e-Form with the viewer option connection.inputjson.
All item values in JSON will be put into the corresponding components in the e-Form automatically.✨
Prepare data string in JSON to fill in customer.ozr
Open
customer.ozr
.Set AllowSending (of input components that you don't want to use) to False.
Preview
Enter field values as you prefer.
Right-click the Hamberger icon on the top-right of the Viewer.
Select Copy input data (json) from the menu list.
Save the copied JSON string as
jsondata.txt
customer-inputjson.html
Open
customer.html
and save it ascustomer-inputjson.html
.Add a variable data and assign its value from the clipboard.
The JSON string must be wrapped with single quotes.
Assign the variable data to the connection.inputjson option.
Get the value of smoker field from the JSON string.
<script type="text/javascript" >
var data = '{"name":"John Kim","n1":"A","n2":"1","n3":"2","n4":"3","n5":"4","n6":"5","n7":"6","n8":"7","n9":"Z","gender":"Male","birth_dd":"05","birth_mm":"09","birth_yyyy":"2000","phone":"+65 1234-5678","email":"[email protected]","country":"Others","country_other":"Korea","address":"Seoul","smoker":"Yes","height":"170","weight":"65","index":"22.49"}';
function SetOZParamters_OZViewer(){
var oz = document.getElementById("OZViewer");
oz.sendToActionScript("connection.servlet", "/training/server");
oz.sendToActionScript("connection.reportname","/forcs/john.kim/customer.ozr");
oz.sendToActionScript("connection.inputjson", data); // pass json data
oz.sendToActionScript("connection.pcount", "1");
oz.sendToActionScript("connection.args1", "smoker=" + JSON.parse(data).smoker);
return true;
}
start_ozjs("OZViewer", "/html5viewer/");
customer.ozr
No need to add a parameter to get the JSON string from HTML.
Show if country_other got a value.
// OnEndBind
if (This.GetValue()) {
This.SetVisible(true);
}
Item names in JSON string must be the same as the Name or FormID of corresponding components in the e-Form.
Using JSON Dataset
customer-jsondataset.ozr
Open
customer.ozr
and save it ascustomer-jsondataset.ozr
.Add a JSON Dataset customer. (refer to the video clip above)
Assign dataset fields to input components.
Add a form parameter jsondata.
Set the Runtime Dataset of the dataset customer to the Parameter(data).
customer-jsondataset.html
Open
customer.html
and save it ascustomer-jsondataset.html
.Send a JSON string to the parameter jsondata
<script type="text/javascript" >
var data = '{"name":"John Kim","n1":"A","n2":"1","n3":"2","n4":"3","n5":"4","n6":"5","n7":"6","n8":"7","n9":"Z","gender":"Male","birth_dd":"05","birth_mm":"09","birth_yyyy":"2000","phone":"+65 1234-5678","email":"[email protected]","country":"Others","country_other":"Korea","address":"Seoul","smoker":"Yes","height":"170","weight":"65","index":"22.49"}';
function SetOZParamters_OZViewer(){
var oz = document.getElementById("OZViewer");
oz.sendToActionScript("connection.servlet", "/training/server");
oz.sendToActionScript("connection.reportname","/forcs/john.kim/customer-jsondataset.ozr");
oz.sendToActionScript("connection.pcount", "1");
oz.sendToActionScript("connection.args1", "jsondata=" + data);
return true;
}
start_ozjs("OZViewer", "/ozviewer/");
</script>
customer-jsondataset.ozr
Tick male or female of the Gender using customer.gender.
Tick Yes or No of the Smoker using customer.smoker.
Show the bmi_band using customer.gender instead of OZFormParam.smoker.
// OnBind
if (This.GetDataSetValue("customer.gender") == "Male") {
This.SetChecked(true);
}
// OnBind
if (This.GetDataSetValue("customer.smoker") == "Yes") {
This.SetChecked(true);
}
// OnBind of the BMI band
if(This.GetDataSetValue("customer.smoker") == "Yes"){
This.SetEnable(true);
}else{
This.SetEnable(false);
}
JSON Dataset from URL
Prepare the URL of the jsondata.txt.
customer-jsondataset-url.ozr
Set the Runtime Dataset of the dataset customer to the Parameter(URL).
Using ODI Dataset
Prefill data in OZR from the database using ODI.
Create customer-odidataset.odi
Import customer-odidataset.odi into customer-odidataset.ozr
<script type="text/javascript" >
function SetOZParamters_OZViewer(){
var oz = document.getElementById("OZViewer");
oz.sendToActionScript("connection.servlet", "/training/server");
oz.sendToActionScript("connection.reportname","/forcs/john.kim/customer-odidataset.ozr");
oz.sendToActionScript("odi.odinames","customer-odidataset");
return true;
}
start_ozjs("OZViewer", "/ozviewer/");
customer-odidataset.ozr
customer-odidataset.odi
Last updated
Was this helpful?