Hi guys,
First post, have just started the mammoth project of turning us paperless.
My first task has been to create a header template - this header to be used on any form we use. I got this done almost without issue, it seems the only complication is to attach the username to the document.
Initially I tried to do this with a text field. I set this up with a calculation script to set this.rawValue = identity.username (also tried identity.name), however further reading taught me that that requires priviledged context (haven't figured out what that is or how to get it yet, but it seems like a 'no' for this method).
My next step has been to attempt to let the user pick their username from a list. "Easy!" I thought, "I just set up a webscript last week to return a configurable list of user details. My web script (it runs off of Alfresco CMS, for the record) is accessed from an URL like https://docs.ourcompany.com:8443/alfresco/service/ourcompany/users?useGroup=[a user group]&filter=[a filter string] and returns JSON like this:
{ "users" : [ { "name" : "Chris O'Kelly", "userName" : "ChrisO" }], "filter" : "all", "error" : 0 }
In the layout:ready script section for my dropdown I have used the following js
function createRequest() { var result = null; if (window.XMLHttpRequest) { // FireFox, Safari, IE>6 result = new XMLHttpRequest(); if (typeof xmlhttp.overrideMimeType != 'undefined') { result.overrideMimeType('application/json'); } } else if (window.ActiveXObject) { // IE <7 alert("No available type"); result = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("No available type"); return; } return result; } var req = createRequest(); req.onreadystatechange = function() { if (req.readyState != 4) return; if (req.status != 200) { alert("REST call failed"); return; } // Request successful, read the response var resp = req.responseText; this.addItem(resp.users.name, resp.users.userName); } req.open("GET", "https://docs.ourcompany.com:8443/alfresco/service/ourcompany/users?useGroup=GROUP_EveryUser&filter=status", true); req.send();
But when I preview the form I get nothing, no errors, no alerts, no filling of the dropdown. I've read a few conflicting forum posts on whether or not xmlHttpRequest works within liveCycle forms, so I suppose the guts of my question boils down to- does it?