StratusForms
StratusForms copied to clipboard
How to display Author field
How do I display a read-only field, such as an author or editor field?
I'd be interested in this, too.
Not sure if there is a better way to do this but I use SPServices to pull the list item data and set span values (see below). Hope that this helps
function GetStaticItemValues() {
var itemID = getUrlParameter("ID"); // or formID based on where you are using it
if(itemID){
$().SPServices({
operation: "GetListItems",
async: false,
listName: [LIST_NAME],
CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Author' /><FieldRef Name='Created' /></ViewFields>",
CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Text'>" + itemID + "</Value></Eq></Where></Query>",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
$("#[MY_CREATED_BY_SPAN_ID]").text($(this).attr("ows_Author").split("#").pop());
$("#[MY_CREATED_DATE_SPAN_ID]").text( $(this).attr("ows_Created")); //might want to format the date
});
}
});
}
}
//Get Url parameter matching passed string parameter (sParam)
function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'),
sParameterName,
i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
}