I’m tweaking the REST sample located here for my custom entity http://msdn.microsoft.com/en-us/library/hh223541.aspx
It retrieves and displays the table for all attributes except money. That is, if my requested attributes don’t include an attribute of type money the table displays. Once I add a money attribute nothing is displayed. Below is my custom html. I’m using the same SDK.OptionSetSample.js included in the sample vs solution.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Contacts Page</title>
<script src="../../ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script src="Scripts/json2.js" type="text/javascript"></script>
<script src="Scripts/SDK.OptionSetSample.js" type="text/javascript"></script>
<script src="Scripts/SDK.MetaData.js" type="text/javascript"></script>
<script src="Scripts/SDK.REST.js" type="text/javascript"></script>
<link href="Styles/OptionSetSample.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
var attributes = [
"new_revenuesportspartnershipsId",
"new_name",
"new_PledgeorCash",
"new_Designation",
"new_DonorStatus"
, "new_FY2011"
];
var ContactListTableData = {
Id: "ContactList",
BodyId: "ContactListBody",
CheckboxColumn: true,
SearchFieldId: "SearchString",
CreateButtonId: "createContact",
DeleteButtonId: "deleteSelectedRecords",
Columns: [
{ Name: "new_name" },
{ Name: "new_PledgeorCash" },
{ Name: "new_Designation" },
{ Name: "new_DonorStatus" }
,{ Name: "new_FY2011" }
]
};
var CurrentContactForm = {
Id: "CurrentContact",
SaveButtonId: "SaveCurrentContact",
CloseFormControlId: "closeFormSpan"
};
window.onload = function () {
SDK.OptionSetSample.Entity = "new_revenuesportspartnerships";
SDK.OptionSetSample.Columnset = attributes;
SDK.OptionSetSample.PrimaryIdAttribute = "new_revenuesportspartnershipsId";
SDK.OptionSetSample.TextSearchAttribute = "new_name";
SDK.OptionSetSample.PrimaryAttribute = "new_name";
SDK.OptionSetSample.TableData = ContactListTableData,
SDK.OptionSetSample.FormData = CurrentContactForm;
//Get the Attribute metadata
SDK.OptionSetSample.getAttributeMetadataCollection.Execute();
}
</script>
</head>
<body>
<ul id="message">
</ul>
<div>
<button id="createContact">
Create</button>
<button id="deleteSelectedRecords" disabled="disabled">
Delete Selected Contacts</button>
<span id="searchBy">Search by Full Name :</span><input id="SearchString" type="text" />
<table id="ContactList" class="RecordList" />
</div>
<div id="CurrentContact" class="editForm">
<span id="closeFormSpan" class="closeFormSpan">X</span>
<!-- Only Boolean, Picklist, Status, and String attribute types are supported in this sample.-->
<div id="new_nameField">
</div>
<div id="new_PledgeorCashField">
</div>
<button id="SaveCurrentContact" disabled="disabled">
Save</button>
</div>
</body>
</html>
The sample script looks like this for Money as it has a case already:
In the two cases outlined, Integer will work fine as it is a primitive type and so will return the actual numerical value into
record[AttributeMetadata.SchemaName].ValueHowever the money type is a complex object so that is assigned to the same variable but wont actually give you the value it represents just the object which is why it isn’t displaying. You actually need a further
.valueon the end to retrieve the numerical value it represents.Either change the switch to this:
or when you put the money attribute in your table make sure that the value that gets shown is
record[AttributeMetadata.SchemaName].Value.valueI think its a lower case for
valueit might be upperValueHope that makes sense.