Display form object data as JSON

The following syntax gives one the possibility of viewing the displayed datagrid page as a JSON object.

page.F_Text1.setContent(toJson(page.F_MyGrid.getDisplayedData(), true))

Can one do the same for a form, i.e., display form data such as 'created' using toJson?

Many thanks

Hi Stephen,

I believe there is no current built in function to achieve that, please create idea in our Ideas Portal.

However, there is workaround, and this is feasible based on the sample application I built for you. Please see attached file.

And for the sample code, I put it on Text item onShow event. I used the idea of REST API call - Retrieve single record via JavaScript in DLeap:

https://help.hcl-software.com/domino-leap/1.1.5/ref_data_rest_api_retrieve.html

/* Add your own JavaScript here. */
// create the url for REST call for Retrieve: https://help.hcl-software.com/domino-leap/1.1.5/ref_data_rest_api_retrieve.html
//make sure the form id matches the form you are going after
var formID ="F_Form1"  
var appURL = app.getAppURL();
var apiURLbase = appURL.replace("-apps/landing/org/app", "-api/secure/org/data");
//current record UID of the form
var recordUid = app.getRecordURL().split("=").pop(); 
var fetchURL = apiURLbase +"/"+formID+"/"+recordUid+"?format=application/json";

// fetch the JSON data from the form
fetch(fetchURL, {
method: “GET”
}).then((response) => {
response.json().then((jsonResponse) => {
// grab “items” array field in the JSON reponse to get data such as “created” of the form
var items = jsonResponse.items
// check if there data is existing, if so, setContent of Text item toJson and display created property of the form
if(items.length != 0) {
page.F_Text1.setContent(toJson(items, true))
const created_property = get(items,0).created;
alert(“Created property of the form/ existing record:” + created_property);
}
})
// close fetch
});

Steps to test:

1. Unzip the file and deploy DLeap app.

2. Go to View Data to check existing data/ record.

3. Click any record and open, it will setContent of Text item toJson and display created property of the form.

- prompt created property:

- set content to Text item:

In addition, there is also way to get current record/ form's other properties such as 'Last Updated On' and 'Last Updated By' via service (in your scenario, you can select 'Creation Time' equivalent of 'Created' as output instead). You can get the idea in this article:

https://support.hcl-software.com/csm?id=kb_article&sysparm_article=KB0115595

Hope this helps. If you have clarifications, please let me know.

Thanks,

Jayve

Test_Retrieve_Form_Data_via_RESTAPI_and_JS_in_DLeap.zip