Quering on the list item collection after being loaded

I'm a newbie to SharePoint and JavaScript.
I have a requirement where in I have to get the count of list column and bind to an HTML element.
Example:
Red,Blue,Green are the columns and i have to get the count of "Red" columns ,"Blue" column and "Green" columns that are filled after loading the items.
//To get the context
var context = new SP.ClientContext.get_current();
//To get the list
var pwh_list = pmh_context.get_web().get_lists().getByTitle('test');
//Query for the list
var pwh_query = new SP.CamlQuery();
//Specifying the xml for the query.
pwh_query.set_viewXml("<GroupBy Collapse='True'><FieldRef Name='Vertical' /></GroupBy><OrderBy> <FieldRef Name='Vertical' Ascending='True' /></OrderBy>");
//Get the items based on the query
var pwh_items = pwh_list.getItems(pwh_query);
//Loading the items
context.load(awh_items);
context.executeQueryAsync(pmh_SuccessItems, pmh_Failitems);
function pmh_SuccessItems()
//Get the count of "Red","Blue","Green" columns
function pmh_Failitems()
These counts have to be bound to the HTML table.
Kindly help.

I din't get the last point. Were you been able to do it?
Just use three different variable for return items pwh_red_items,pwh_blue_items
context.load(pwh_red_items);context.load(pwh_blue_items);
Then on success use pwh_red_items.Count
, pwh_blue_items.Count something like this
Please mark a post helpful/answer if it is really helpful or answer your query

Similar Messages

  • Termstore changes are not getting reflected in the list items in SharePoint 2010 farm environment

    Hi,
    I had created managed metadata with termstores from central admin. Then I had created one list in which added a column of type managed metadata using the managed metadata which I had created. And also added few list items to this list.
    The problem is that after updating a termstore the changes are not reflecting in the list items which were added before the update.
    I have referred the following links:
    http://www.paulgrimley.com/2011/02/managed-metadata-changes-not-applied-to.html
    http://davidfrette.wordpress.com/2010/05/26/taxonomy-update-scheduler%C2%A0timer%C2%A0job/
    According to the links we need to run Taxonomy Update Scheduler on the server for updated termstore to get reflected. After running
    this scheduler on development environment changes are getting reflected but not working on the production environment.
    Kindly help!
    Regards, Shruti

    You should check the obvious.  You made the change in dev, but did you make the change in production too?  And, is the term you updated, actually the one that you are looking at in the list item?
    There is not much, if anything, that can go wrong with that timer job. so I'd guess that the term you are looking at is not the one you think you are updating.
    If you have double checked everything (the term is is in fact the same term id), then you may have something erroring in the update process.  In this case, you should check the ULS logs for any errors.
    Chris
    Chris Givens CEO, Architecting Connected Systems
    Blog Twitter

  • Invalid data has been used to update the list item. The field you are trying to update may be read only (Lookup Field).

    Hi.
    I am getting below error while adding value to look-up field.
    Invalid data has been used to update the list item. The field you are trying to update may be read only.
    I have tried many forums ans post but didn't come to know what's the root cause of issue. I am also posting Code for creating and adding lookup field.
    CAML to create lookup field (It works Fine)
    string lkproductNumber = "<Field Type='Lookup' DisplayName='Product Number' StaticName='ProductNumber' ReadOnly='FALSE' List='" + pNewMaster.Id + "' ShowField='Product_x0020_Number' />";
    Code to insert value to lookup field
    ClientContext client = new ClientContext(SiteUrl);
    client.Load(client.Web);
    client.Credentials = new NetworkCredential(this.UserName, this.Password, this.Domain);
    // Lookup Lists
    List pmList = client.Web.Lists.GetByTitle("Product_Master");
    //List Conatining Lookup Columns
    List piList = client.Web.Lists.GetByTitle("Product_Inventory");
    client.Load(piList);
    query.ViewXml = "<View/>";
    ListItemCollection collection = pmList.GetItems(query);
    client.Load(collection);
    client.ExecuteQuery();
    int prodid=0;
    foreach (ListItem item in collection)
    if (Convert.ToString(item["Product_x0020_Number"]) == ProductNumber)
    { prodid = Convert.ToInt32(item["ID"]); }
    ListItem piItem = piList.AddItem(new ListItemCreationInformation());
    piItem["Product_x0020_Number"] = new FieldLookupValue() { LookupId = prodid };
    piItem.Update();
    client.ExecuteQuery();
    Exception Detail
    Microsoft.SharePoint.Client.ServerException was caught
    Message=Invalid data has been used to update the list item. The field you are trying to update may be read only.
    Source=Microsoft.SharePoint.Client.Runtime
    ServerErrorCode=-2147352571
    ServerErrorTypeName=Microsoft.SharePoint.SPException
    ServerStackTrace=""
    StackTrace:
    at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)
    at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()
    at WebServiceProviders.ClientServices.NewProductInventory() in Z:\.............ClientServices.cs:line 889
    InnerException:
    Quick response is highly appreciated.
    Thanks
    Mehar

    Try some thing like below,
    your data value that needs to be update should be in this format "ID of the lookup";#"Title of the Lookup" 
    For example,
    listItem["Product_x0020_Number"]
    = "1;#iPhone";
    listItem["Product_x0020_Number"]
    = "2;#Mobile";
    Hope this helped you....

  • Manually Arranging the List of Collections

    I just downloaded and installed LR 1.0. I was also able to successfully import my LR 4.1beta Library with no problem. My question is: does anyone know how to manually arrange the list of Collections in LR 1.0? Right now they are listed alphabetically, but I would like to have the list of Collections displayed otherwise.
    In iPhoto, you can click and drag a specific iPhoto Library then move and place it wherever you want in the iPhoto Library list.
    Any help on how to do this would be appreciated.

    Thanks, Sid. That's a workaround for what I want to do, but I would like to arrange my Collections in chronological order (using Month Year) as the Collection name (i.e., FEB 2007) and would like to have the most recent images in the Collection at the top of the Collection list.
    In other words, if I started setting up my Collection list today, I would like to have it arranged FEB 2007, JAN 2007, DEC 2006, ... with FEB 2007 at the top. Right now, I haven't figured out a way to do that.
    Unfortunately, using the child collections the way you suggested, I would have to rename each Collection everytime I added a new Collection (named after the current Month Year) to keep the most recent Collection at 001.

  • Error: "The workflow could not delete the list item"

    Have set up 2 lists:  Events and EventsArchive.  They have all the same fields.  I have created a workflow in SPD using an impersonation step (I have Full control of the site/site collection).  Workflow is essentially this:
        If Curent Item:Expired 
    equals
    Yes
           Copy item in Current Item to
    EventsArchive
           then Delete item in
    Current Item.
    The item is copying over to the EventsArchive list just fine, but the "delete" part is not happening.  Instead, I get the following error:
    The workflow could not delete the list item. Make sure the list exists and the user has permissions to delete items in the list.
    The list obviously exists (or I wouldn't be able to copy an item from it), and I have as much permissions as anyone can have, so I'm not sure where else to turn with this. 
    Thanks in advance for your help!

    Hi,
    To test the issue, I create a simple workflow without using Impersonation step:
    It works.
    Could you please create new lists to avoid custom settings and test the issue again?
    Similar thread:
    https://social.msdn.microsoft.com/Forums/office/en-US/3fa94026-4487-4e4c-a5b4-12a79d6ee6a2/workflow-delete-item-not-working?forum=sharepointcustomizationprevious
    Regards,  
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Need to update the list item in the same sharepoint list with particular condition with Sharepoint Designer 2013.

    Hi All
    I have one sharepoint list with huge data i.e with 20columns and more than 200 records with the fields .
    Suppose lets consider there are A,B,C,D,E,F,G,H columns.
    Now i want to create one form with the fields A,C,E.
    When the user enter the existing data of list for columns A,C..based on C value the E column value should change and update that particular item in the list.
    Please guide me without visual web part can we acheive this by Sharepoint designer 2013 or what would be the preferable solution.
    Please help me on this as it is very urgent from me..
    Thanks in Advance
    Sowjanya G

    Hi,
    According to your post, my understanding is that you wanted to update the list item in the same sharepoint list with particular condition with Sharepoint Designer 2013.
    I recommend to create workflow associated to the list and then start the workflow automatically when an item is changed.
    In the workflow, you can add condition and actions as below:
    If current item: C equal to Test1
         Set E to Test2
    Then the value of the filed E will be changed based on the value of the filed C.
    In addition, if you create the form using InfoPath, you can add rule to the filed C as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to implement tooltip for the list items for the particular column in sharepoint 2013

    Hi,
    I had created a list, How to implement tooltip for the list items for the particular column in SharePoint 2013.
    Any help will be appreciated

    We can use JavaScript or JQuery to show the tooltips. Refer to the following similar thread.
    http://social.technet.microsoft.com/forums/en/sharepointdevelopmentprevious/thread/1dac3ae0-c9ce-419d-b6dd-08dd48284324
    http://stackoverflow.com/questions/3366515/small-description-window-on-mouse-hover-on-hyperlink
    http://spjsblog.com/2012/02/12/list-view-preview-item-on-hover-sharepoint-2010/

  • Validation settings for a list in Sharepoint 2010 to find if there is a document attached to the list item

    Hi Everyone,
    Greetings!!!
    I have a very peculiar question on List validation settings. I want to validate a list item whether user has attached a document to the list item or not? The list item should not be saved until a document is attached to it. Is it possible to perform this
    validation for a list item in a list?
    Please let me know.
    Thanks,
    Thiru
    Tirumal

    Can be done using java script as below
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/c93d7611-f634-4c03-ae0d-3b5ecfe5ca6a/how-to-make-attachment-required-field?forum=sharepointadminlegacy
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/5a3fe11a-75ea-44bd-aab9-80817640290f/how-to-make-an-attachment-required-field-in-a-custom-newform-sharepoint-2010-list?forum=sharepointcustomizationprevious
    Dont think below is right
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/fba48bc1-8708-401c-8a37-bc00f77eeae3/making-attachments-required-in-a-custom-list?forum=sharepointadminlegacy

  • WebPart is raising the following error "Invalid data has been used to update the list item.The field you are trying to update may be read only"

    I have created a farm solution and then i deploy it to SharePoint server, the code looks as follow, and i use it to update a page info values (as the current page values represents old info):-
    [ToolboxItemAttribute(false)]
    public partial class VisualWebPart1 : WebPart
    // Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
    // the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
    // for production. Because the SecurityPermission attribute bypasses the security check for callers of
    // your constructor, it's not recommended for production purposes.
    // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
    public VisualWebPart1()
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    InitializeControl();
    using (SPSite site = new SPSite(SPContext.Current.Site.Url))
    using (SPWeb web = site.OpenWeb())
    SPList list = web.Lists["Pages"];
    web.AllowUnsafeUpdates = true;
    foreach (SPListItem items in list.Items)
    items["Author"] = "SharePoint";
    items["Created"] = "01/08/2014 01:44 PM";
    items.Update();
    list.Update();
    web.AllowUnsafeUpdates = false;
    protected void Page_Load(object sender, EventArgs e)
    but when i try adding this web part to a page i got the following error:-
    Invalid data has been used to update the list item.The field you are trying to update may be read only
    so can anyone advice?

    i only changed lines bitween 
    web.AllowUnsafeUpdates = true;
    and
    web.AllowUnsafeUpdates = false;
    and other parts of code remains without change
    so it will updates all pages in current web
    yaşamak bir eylemdir

  • Invalid data has been used to update the list item. The field you are trying to update may be read only.

    Trying to follow Serge Luca's Step by Step Tutorial. Creating Workflows for Windows Sharepoint Services and MOSS2007.  http://sergeluca.spaces.live.com/blog/cns!E8A06D5F2F585013!859.entry
    I have an onWorkflowActivated, followed by an ifElse condition and a log to history.
    In the IfElse, each branch has a code segment, that trys to update the status column in the list that the workflow is attached to.
    private void Authorize_ExecuteCode(object sender, EventArgs e)
    // tried serveral methods
    WorkflowProperties.Item["Status"] = "Automatically Approved";
    // tried all of the following (one at a time)
    item.update();
    WorkflowProperties.Item.Update();
    WorkflowProperties.Item.SystemUpdate();
    //tried this as well.
    Microsoft.SharePoint.SPListItem item = WorkflowProperties.Item;
    item["Status"] = "Automatically Approved";
    item.Update() ;
    On the update call I keep getting "Invalid data has been used to update the list item. The field you are trying to update may be read only."
    Could someone explain how to update "Status" column of the list item that the workflow is working on?
    Thank you very much.
    Bill
     

    Hi:
    you can do the following:
    add the following code to the workflow.xml file (under the MetaData section)
    Code Snippet
    <ExtendedStatusColumnValues>
    <StatusColumnValue>Branch1</StatusColumnValue>
    <StatusColumnValue>Branch2</StatusColumnValue>
    </ExtendedStatusColumnValues>
    then add 2 SetState activities one in each branch of the IfElse.
    for the code behind of setState1 (branch1) write the following code:
    Code Snippet
    state = Convert.ToInt32(SPWorkflowStatus.Max);
    for setState2 (branch2) write the following:
    Code Snippet
    state = Convert.ToInt32(SPWorkflowStatus.Max) + 1;
    where state is the variable assigned to the field State in the properties of the SetState(design lever), or instead of state u can use the following code:
    Code Snippet
    ((SetState)sender).State
    where sender is the object sent through the function parameter.
    hope this answered your question
    Best Regards

  • The workflow could not check out the list item.

    Hi Guys,
    I have a workflow enabled on document library and it needs to started manually.
    Whenever user starts workflow manually, gets following error:
    "the workflow could not check out the list item. Make sure the list item is not checked out." list item is not checked out & this workflow was working smoothly earlier.
    OutCome: The workflow operation failed because the workflow lookup found no matching item.
    I have gone through below links:
    https://christopherclementen.wordpress.com/2014/05/23/oob-approval-workflow-error/
    https://social.msdn.microsoft.com/Forums/office/en-US/f673d0f6-92eb-4057-95ff-ed3cb7790360/the-workflow-operation-failed-because-the-workflow-lookup-found-no-matching-item?forum=sharepointcustomizationprevious
    Any clue on this?
    Thanks, Nilesh

    maybe check out for editing documents setting is turned on so wokrflow needs doc to ce cheked out before proceding and user might not have permission to do that.
    please refer below link:
    http://sharepoint.stackexchange.com/questions/32399/workflow-error-the-workflow-could-not-update-the-item-possibly-because-one-or
    http://community.office365.com/en-us/f/154/t/243062.aspx
    http://stackoverflow.com/questions/1272957/document-checked-out-in-sharepoint-when-workflow-starts
    Please mark as answer if you find it useful else vote for it if it is close to answer..happy sharepointing

  • How to display the Attachment(picture) on the list item page?

    I have attached a picture to the list item and then when I click the item, there is a link of the attachment but not the picture graphics! I want to display the picture on the list item page and how to do it?
    I am a beginner of SharePoint 2010 and my English is not very good! Thanks!

    Hi,
    Using few easy steps you can set image in your out of the box List View, Edit and View Item Page.
    1. Create one Picture type Column in your list.
    2. Just create one Event Handler with Item
    /// <summary>
    /// An attachment was added to the item.
    /// </summary>
    public override void ItemAttachmentAdded(SPItemEventProperties properties)
    base.ItemAttachmentAdded(properties);
    SPListItem item = properties.ListItem;
    //SPAttachmentCollection attach = item.Attachments;
    string attachmentUrl = item.Attachments.UrlPrefix + item.Attachments[0];
    item["PictureColumnName"] = attachmentUrl;
    item.Update();
    Now, just add item with attachment and you will see attached image in Picture Column field.
    Manoj | SharePoint

  • How to avoid the Blank elemts in the List Item

    Dear All,
    I am using a List Item
    List Elements List Item Value
    Yes 1
    No 2
    Only two elements in this List Item.But at Run time there is one Blank element.
    I need to display only two elements from the List Item .How to avoid the Blank.
    Thanks and Regards,
    Fazil

    Fazil,
    I am using a List ItemList Elements List Item Value
    Yes 1
    No 2
    Only two elements in this List Item.But at Run time there is one Blank element.
    I need to display only two elements from the List Item .How to avoid the Blank.>
    Maybe you actually have null entries in your list. You can clean it up using keys as discussed here http://paranoid-engineering.blogspot.in/2008/05/wonderland-of-oracle-forms-builder.html (Ignore the personal opinions of the author if you will ;) ).
    Cheers,

  • How to modify the list item drop down context menu in SharePoint 2010

    Hi All,
    I have a requirement to add my name in the list item drop down context menu, already "Assigned ticket" option is available in the context menu and some names are available in the assigned ticket option. but i can't able to add my name in this options.
    Attached screenshot for reference. Thanks in advance for your assistance!
    Thanks
    Arun Prakash

    Do you know how the currently listed values got there in the first place? Some sort of custom code or action? Some background information would help. There is obviously a source feeding it from somewhere, but it's impossible for us to tell you exactly
    what just by looking at your scribbled-over screenshot
    Check WSPs that are deployed to the farm. Check for any non-OOTB site features that are turned on...

  • My Lightroom kepps stopping just after being loaded. My Lightroom is 5.4 64 bits installed on a Dell PC with Windows 8.1(upgraded from 8). I have uninstalled Lightroom and re-installed it with the same result. What could be the problem?

    My Lightroom kepps stopping just after being loaded. My Lightroom is 5.4 64 bits installed on a Dell PC with Windows 8.1(upgraded from 8). I have uninstalled Lightroom and re-installed it with the same result. What could be the problem?

    Try resetting your preference file next: http://www.lightroomforums.net/showthread.php?14226-Resetting-(or-Trashing-)-the-Lightroom -Preferences-file
    It survives an uninstall/reinstall.

Maybe you are looking for

  • Who can help me use Time Machine to find some photos from a year ago?

    I need to know how to retrieve some photos from a year ago that should be stored on my ext. drive.  I have Time Machine....Mac OSX 10.9.1.  I have tried to do it and Time Machine tells me there is not enough room to download my old Picture Library. 

  • Cannot open the zip attachment in pdf file

    I am using the Adobe Acrobat 8.1.2 professional and i attach the zip file in the pdf file after that, the user that just use the Adobe Reader 8.1.2 cannot open the Adobe zip attachment. Do i do any one in add the attachment or the Reader cannot open

  • Why is the Robohelp webhelp search so slow?

    Hello, I currently use Robohelp 9 and produce merged Webhelp using Zoomsearch v6 as the search engine. My sites has around 2500 topics and 26 merged projects. Zoomsearch produces search results in under half a second. I decided to use zoomseach (afte

  • Asset Table TABA can't be udpated.

    Dear All, In my user's production system, asset fiscal year was set to 2009. In 2008, no asset was created and posted depreciation (TABA: On 2007 12, the posted document is N. Before 2007 12, it is X). In 2009 Jun, user created an asset and wanted to

  • How to update a table when exception?

    The form contains only 1 block, a control block, which will trigger a oracle report when user save it. It will insert a record into a table. If report generate successfully, it will update the status to completed and vice versa. How can I do so? Beca