我在这方面遇到了很多麻烦。本质上,我试图计算 Decommission 出现在特定列表列中的次数。据我所知,javascript是正确的,但它不起作用。任何人都可以提供一些指导吗?谢谢!
<script type="text/javascript">
var myItems = null;
var siteUrl = 'https://chartiscorp.sp.ex3.secureserver.net/'
function SuperDuper()
{
var queryString = '<View><Query><Where><Gt><FieldRef name="End State" /><Value Type="String">Decommission</Value></Gt></Where></Query></View>';
var myContext = new SP.ClientContext(siteUrl);
var myWeb = myContext.get_web();
var myList = myWeb.get_lists().getByTitle('System_Information');
var myQuery = new SP.CamlQuery();
myQuery.set_viewXml(queryString);
myItems = myList.getItems(myQuery);
myContext.load(myItems,'Includes(End State)');
myContext.executeQueryAsynch(Function.createDelegate(this,SuperDuperSuccess),Function.createDelegate(this,SuperDuperFail));
}
function SuperDuperFail(sender, args)
{
alert('Failed ' + args.get_message());
}
function SuperDuperSuccess(sender, args)
{
var endStateEnumerator = myItems.getEnumerator();
var decommCount = 0;
while(endStateEnumerator.moveNext())
{
//var currentEndState = endStateEnumerator.get_current();
decommCount = decommCount + 1;
}
alert(decommCount);
}
window.onload = SuperDuper;
</script>