0

I am having a lot of trouble with this. Essentially, I am trying to count the number of times Decommission appears in a particular list column. From what I can tell, the javascript is correct, but it doesn't work. Can anyone provide some guidance? Thanks!

<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>
Mahmoud Farahat
  • 5,364
  • 4
  • 43
  • 59

1 Answers1

0

What is the error? Have you tried to see the script error it is throwing?

In function SuperDuperSuccess() you can simply put

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

No need to write while loop .

Pls try to put alert and after some line and see what is coming.