Display iSheet Data on Home Page/Wiki

27343

I recall that there is a simple way to display iSheet records on a site's home page (or wiki) in a table or single-item format.  I'm referring to data from each individual row as opposed to charts and other aggregate data visualizations.  However, I haven't been able to find the instructions.  Any assistance would be appreciated.  I'm trying to display iSheet data in a more user-friendly manner by, for example, placing the contents of each column in a separate row, with each iSheet row corresponding to a separate table on the home page/wiki.

 

Simplified example:

(1)  This is my iSheet record:

 

Client Name Client Jurisdiction Client Code Client Mailing Address Client Relationship Manager(s)
Acme Co. Delaware 1234567 123 5th Ave., New York, New York Bob Smith; Amy Jones

 

(2)  I'd like to generate the following on the home page/wiki (including a link at the bottom that would allow the user to edit that particular record):

 

Client Name Acme Co.
Client Jurisdiction Delaware
Client Code 1234567
Client Mailing Address 123 5th Ave., New York, New York
Client Relationship Manager Bob Smith; Amy Jones

Edit Record [THIS LINK WOULD TRIGGER AN EDIT OF THE RECORD

 

]]>
Parents
  • Hi Steve Mann, when you say "I used JavaScript to call the iSheet API", I assume you mean from a NodeJS server, or a client-side stub that calls a proxy (API) service? Otherwise it would mean you are exposing your secret key (to generate a token) on the client-side. This is a big No-No, and would fail any security audit, voiding any (cyber)security framework/ISO 27001.

    -----

    Aside from this, for info to others reading this thread: If you add "application/json" to the Accept header of the API request, then the response will be JSON which, for JavaScript, is much easier to consume and process than XML. Normally JSON would also be slightly more performant than XML in that the payload is smaller - no closing tags inflating payload size, however, the Collaborate API's format the response JSON with spaces, the result being that the responses are larger than XML responses!! The other plus side to XML is that you can walk back up the parent/child hierarchy, which you can't with JSON, i.e. you can't ask a child (key/value pair) what it's parent is.

    EDIT: Correction, Collaborate API's do not format the raw (JSON) responses, so these responses are smaller - approx. half the size of XML - which makes a difference with larger iSheet result sets. If you are used to using XPath or similar with XML, you can include JSONPath to perform something akin to this with JSON data.

    Another tip is that if you have the XML response, you can load this into JQuery using (assuming we're in Collaborate):

    var $xml = $j($j.parseXML(xmlResponse));

    We can then use JQuery selectors, as we normally would, to get at the nodes, e.g.

    // column headings
    $xml.find("columnvalue").map(function() { 
       return $j(this).text();
    });
    
    // data
    var $data = $xml.find("item").map(function() {
    	return $j(this).find("column").map(function() {
    		var $column = $xml.find("headcolumn[columnid=" + $j(this).attr("attributecolumnid") + "
    ); switch($column.attr("columntypealias")) { case "SHEET_COLUMN_TYPE_CHOICE": return $j(this).find("displaydata label").text(); case "SHEET_COLUMN_TYPE_LOOKUP": return $j(this).find("displaydata email").text(); default: return $j(this).find("displaydata value").text(); } }); }); // e.g. output to console - converting JQuery containers to standard arrays console.table($data.toArray().map(function(el) { return $j(el).toArray(); }));

    All that being said, the easiest way to get at iSheet data from within Collaborate (via Javascript) is to use the ExportXML link, shown in the top part of the iSheet Admin Module when you edit an iSheet View - though this approach does not return useful information for File/Folder/Image/Attachment columns, and it will need paging for large result sets. But at least you don't need to mess about with API access tokens, and creating proxy services.

    Andrew

    ]]>
Reply
  • Hi Steve Mann, when you say "I used JavaScript to call the iSheet API", I assume you mean from a NodeJS server, or a client-side stub that calls a proxy (API) service? Otherwise it would mean you are exposing your secret key (to generate a token) on the client-side. This is a big No-No, and would fail any security audit, voiding any (cyber)security framework/ISO 27001.

    -----

    Aside from this, for info to others reading this thread: If you add "application/json" to the Accept header of the API request, then the response will be JSON which, for JavaScript, is much easier to consume and process than XML. Normally JSON would also be slightly more performant than XML in that the payload is smaller - no closing tags inflating payload size, however, the Collaborate API's format the response JSON with spaces, the result being that the responses are larger than XML responses!! The other plus side to XML is that you can walk back up the parent/child hierarchy, which you can't with JSON, i.e. you can't ask a child (key/value pair) what it's parent is.

    EDIT: Correction, Collaborate API's do not format the raw (JSON) responses, so these responses are smaller - approx. half the size of XML - which makes a difference with larger iSheet result sets. If you are used to using XPath or similar with XML, you can include JSONPath to perform something akin to this with JSON data.

    Another tip is that if you have the XML response, you can load this into JQuery using (assuming we're in Collaborate):

    var $xml = $j($j.parseXML(xmlResponse));

    We can then use JQuery selectors, as we normally would, to get at the nodes, e.g.

    // column headings
    $xml.find("columnvalue").map(function() { 
       return $j(this).text();
    });
    
    // data
    var $data = $xml.find("item").map(function() {
    	return $j(this).find("column").map(function() {
    		var $column = $xml.find("headcolumn[columnid=" + $j(this).attr("attributecolumnid") + "
    ); switch($column.attr("columntypealias")) { case "SHEET_COLUMN_TYPE_CHOICE": return $j(this).find("displaydata label").text(); case "SHEET_COLUMN_TYPE_LOOKUP": return $j(this).find("displaydata email").text(); default: return $j(this).find("displaydata value").text(); } }); }); // e.g. output to console - converting JQuery containers to standard arrays console.table($data.toArray().map(function(el) { return $j(el).toArray(); }));

    All that being said, the easiest way to get at iSheet data from within Collaborate (via Javascript) is to use the ExportXML link, shown in the top part of the iSheet Admin Module when you edit an iSheet View - though this approach does not return useful information for File/Folder/Image/Attachment columns, and it will need paging for large result sets. But at least you don't need to mess about with API access tokens, and creating proxy services.

    Andrew

    ]]>
Children
No Data