0

我在这方面遇到了很多麻烦。本质上,我试图计算 Decommission 出现在特定列表列中的次数。据我所知,javascript是正确的,但它不起作用。任何人都可以提供一些指导吗?谢谢!

<script type="text/javascript">
                        var myItems = null;
                        var siteUrl = &apos;https://chartiscorp.sp.ex3.secureserver.net/&apos;

                        function SuperDuper()
                        {
                            var queryString = &apos;<View><Query><Where><Gt><FieldRef name="End State" /><Value Type="String">Decommission</Value></Gt></Where></Query></View>&apos;;
                            var myContext = new SP.ClientContext(siteUrl);
                            var myWeb = myContext.get_web();
                            var myList = myWeb.get_lists().getByTitle(&apos;System_Information&apos;);
                            var myQuery = new SP.CamlQuery();

                            myQuery.set_viewXml(queryString);
                            myItems = myList.getItems(myQuery);

                            myContext.load(myItems,&apos;Includes(End State)&apos;);
                            myContext.executeQueryAsynch(Function.createDelegate(this,SuperDuperSuccess),Function.createDelegate(this,SuperDuperFail));
                        }

                        function SuperDuperFail(sender, args)
                        {
                            alert(&apos;Failed &apos; + 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>
4

1 回答 1

0

错误是什么?您是否尝试过查看它抛出的脚本错误?

在函数 SuperDuperSuccess() 你可以简单地把

 var count=0;
 count=this.myItems.get_count();

无需编写 while 循环。

请尝试发出警报并在某些行之后看看会发生什么。

于 2013-07-21T04:46:59.900 回答