How to retrive list item form sub folder (sub folders) in sharepoint using CAML or Server Object Model?

Hi All,
I have multiple folders in document library.I want to retrive list item form folder.
Following is snap
I want to get all sub folder and list item in
Sub folder 1.
Any will be help appreciated..
Thanks
Balaji More

Hi Balaji,
If
you want to query all folders and sub folders of a list or document library, you have to define extra query options. If you are working with the object model you have to set the
ViewAttributes property of the SPQuery object as follows:
qry.ViewAttributes = "Scope='Recursive'";
you can use the client 0bject model to get this as well
ClientContext clientContextObj =
new ClientContext("http://Servername/");
List yourDocLib = clientContextObj.Web.Lists.GetByTitle("Shared Documents");
CamlQuery camlQueryObj = new CamlQuery();
camlQueryObj.ViewXml =
@"<View Scope='Recursive' />";
ClientOM.ListItemCollection listItems =
yourDocLib.GetItems(camlQuery);
clientContextObj.Load(listItems);
clientContextObj.ExecuteQuery();
foreach (var item in listItems)
Krishana Kumar http://www.mosstechnet-kk.com

Similar Messages

  • Please tell me how to handle list item in this concern

    please tell me how to handle list item in this concern
    My problem is:
    i have a category table with column categoryname(varchar type)
    I want to display the records of categoryname in a drop down list (i.e., list item )
    So ..please tell me how to do it
    Thanks in advance..

    This code is just a sample from the Help documentation. It won't work until you modify it for your form.
    Why do you have "steps" in your code? You are suppose to do what the steps tell you. You don't place the steps in your code. The steps must be removed from your code.
    Step 1 code goes in a program unit, not in a trigger.
    Step 2 and 3 code usually goes in a trigger.
    You will have to replace the names of the items and record group with your own names as you have defined them in your form.
    step 1: create a procedure in your application
    procedure load_list(itm in VARCHAR2, rg in VARCHAR2) is
    group_id RecordGroup := Find_Group(rg);
    list_id Item := Find_Item(itm);
    Begin
    if Populate_Group(group_id)<>0 then
    Message('Unable to populate record group');
    Raise Form_Trigger_Failure;
    end if;
    Clear_List(list_id);
    Populate_list(list_id, group_id);
    end;
    step 2: create a record group named rg_cat and assign Record Group Query to something like "select categoryname from category"
    step 3: call this procedure as
    load_list('categoryname','rg_cat');

  • How do I organise items in a folder?

    How do I organise items in a folder?  There is probably a really simply answer!  I want to change the order of items listed, but dragging doesnt work...

    mrstrong98,
    The solution you suggested is indeed the right one.  Just a few extra suggestions.  When prefixing filenames with numbers for sorting purposes, you should really use leading zeros to assure that they will sort correctly on your mac and any other devices.  So, if there is any chance that your book will have more than 9 chapters, then you should number them like this:
    01 - My first chapter
    02 - Another chapter
    03 - Yet another
    12 - The last chapter
    I would suggest a similar naming scheme for any files that you need to always sort in a particular manner that can't be accomplished with the built in sorts.

  • How to copy List item from one list to another using SPD workflow using HTTP call web service

    Hi,
    How to copy List item from one list to another using SPD workflow using HTTP call web service.
    Both the Lists are in different Web applications.
    Regards, Shreyas R S

    Hi Shreyas,
    From your post, it seems that you are using SharePoint 2013 workflow platform in SPD.
    If that is the case, we can use Call HTTP web service action to get the item data, but we cannot use Call HTTP web service to create a new item in the list in another web application with these data.
    As my test, we would get Unauthorized error when using Call HTTP web service action to create a new item in a list in another web application.
    So I recommend to achieve this goal programmatically.
    More references:
    https://msdn.microsoft.com/en-us/library/office/jj164022.aspx
    https://msdn.microsoft.com/en-us/library/office/dn292552.aspx?f=255&MSPPError=-2147217396
    Thanks,
    Victoria
    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]

  • How to get List Item attachments name without write any custom code or any database query?

    Hi,
    How to get List Items attachments name without write any custom code or any database query?

    You can get it from Rest,
    There are 2 options,
    1) create a 'Result Source' which has a search query for that List which has attachments 
     - Use rest query to get the 'Filename' , it will have the attachment file name 
    For example, if the result source id is : 73e6b573-abf8-4407-9e5f-8a85a4a95159 , then the query will be 
    http://[site URL]/_api/search/query?querytext='*'&selectproperties='Title,Path,FileExtension,SecondaryFileExtension,Filename'&sourceid='73e6b573-abf8-4407-9e5f-8a85a4a95159'&startrow=0&rowLimit=100
    You can refine the query, be giving proper 'querytext'
    2) Use the List rest api
    For example if your list guid is :38d524a1-e95c-439f-befd-9ede6ecd242e
    You can get he attachments for 1st item using this 
    http://[Site URL]/_api/lists(guid'38d524a1-e95c-439f-befd-9ede6ecd242e')/items(1)/AttachmentFiles
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • How to store list item in hidden field?

    I want to store the list item value of SharePoint 2013 in a input type hidden field.
    And then want to get that items client side.
    How can I store that value to <Input type="Hidden"/>  field?
    Thanks in Advance.

    Hi,
    If you want to get the value of list item from client side, a recommended way is using
    JavaScript Client Object Model.
    With JavaScript Client Object Model, we can write code with JavaScript to access SharePoint objects from client side dynamically.
    The links below about JavaScript Client Object Model for your reference:
    http://msdn.microsoft.com/en-us/library/office/hh185006(v=office.14).aspx
    More information about JavaScript Client Object Model:
    http://msdn.microsoft.com/en-us/library/office/hh185011(v=office.14).aspx
    http://msdn.microsoft.com/en-us/library/office/hh185015(v=office.14).aspx
    Best regards
    Patrick Liang
    TechNet Community Support

  • Bridge Freezes when Show Items From Sub Folders

    Hi all. I am trying to create a portfolio of past works. Using Adobe Bridge and Show Items From Sub Folders makes it easy to go through thousands of files. One major problem though; Bridge is not stable. When I try to view a folder with thousands of files Bridge will freeze and I have to force quite.
    I am running a Mac Pro with Adobe Design CS4 Premium installed. I have 16gb of Ram and have played around with Bridge's preferences and deleted Bridges preference files. I also tried all the options list on Adobe's check list.
    Any help would be greatly appreciated.
    Regards
    Stephen Thompson

    Bridge is not stable. When I try to view a folder with thousands of files Bridge will freeze and I have to force quite.
    As a matter of fact, bridge CS4 is the most stable version of bridge, and although still not perfect yo should be able to view the folder in flat view.
    It only takes a lot of time to cache if you have not done before. If cache does not start you first should try to purge cache for folder using the tools menu.
    If Bridge keeps freezing first thing to try is to restart holding down option key and choose reset preferences. Set prefs again to your own wishes and try again.
    You can also try to first cache the folder using the tools menu. In the folderpanel select the main folder you want to view its contents and go to the tools menu / cache and this time select build and export cache.
    Depending on the amount and size of files it takes some time. Then try again.
    It is able to work, as it does on my system. I have also a main folder that contains around 5000 files organized in stacks and works as it should

  • The last few times I imported photos, the backup location was set to "documents" with no sub-folders. How do I get them into sub-folders - like year and month?

    the last few times I imported photos, the backup location was set to "documents" with no sub-folders. How do I get them into sub-folders - like year and month?

    Use the Subfolder pulldown to set the subfolders:

  • How to create a Document Set in SharePoint 2013 using JavaScript Client Side Object Model (JSOM)?

    Hi,
    The requirement is to create ""Document Sets in Bulk" using JSOM. I am using the following posts:-
    http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/1904cddb-850c-4425-8205-998bfaad07d7/create-document-set-using-ecma-script
    But, when I am executing the code, I am getting error "Cannot read property 'DocumentSet' of undefined "..Please find
    below my code. I am using Content editor web part and attached my JS file with that :-
    <div>
    <label>Enter the DocumentSet Name <input type="text" id="txtGetDocumentSetName" name="DocumentSetname"/> </label> </br>
    <input type="button" id="btncreate" name="bcreateDocumentSet" value="Create Document Set" onclick="javascript:CreateDocumentSet()"/>
    </div>
    <script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"> </script>
    <script type="text/javascript">
       SP.SOD.executeFunc('sp.js','SP.ClientContext','SP.DocumentSet','SP.DocumentManagement.js',CreateDocumentSet);
    // This function is called on click of the “Create Document Set” button. 
    var ctx;
    var parentFolder;
    var newDocSetName;
    var docsetContentType;
    function CreateDocumentSet() {
        alert("In ClientContext");
        var ctx = SP.ClientContext.get_current(); 
        newDocSetName = $('#txtGetDocumentSetName').val(); 
        var docSetContentTypeID = "0x0120D520";
        alert("docSetContentTypeID:=" + docSetContentTypeID);
        var web = ctx.get_web(); 
        var list = web.get_lists().getByTitle('Current Documents'); 
        ctx.load(list);
        alert("List Loaded !!");
        parentFolder = list.get_rootFolder(); 
        ctx.load(parentFolder);
        docsetContentType = web.get_contentTypes().getById(docSetContentTypeID); 
        ctx.load(docsetContentType);
        alert("docsetContentType Loaded !!");
        ctx.executeQueryAsync(onRequestSuccess, onRequestFail);
    function onRequestSuccess() {       
        alert("In Success");
        SP.DocumentSet.DocumentSet.create(ctx, parentFolder, newDocSetName, docsetContentType.get_id());
        alert('Document Set creation successful');
    // This function runs if the executeQueryAsync call fails.
    function onRequestFail(sender, args) {
        alert("Document Set creation failed" + + args.get_message());
    Please help !!
    Vipul Jain

    Hello,
    I have already tried your solution, however in that case I get the error - "UncaughtSys.ArgumentNullException: Sys.ArgumentNullException:
    Value cannot be null.Parameter name: context"...
    Also, I tried removing SP.SOD.executeFunc
    from my code, but no success :(
    Kindly suggest !!!
    Vipul Jain

  • How to populate List Item from the table in a form builder

    I want to know how to populate the List Item (pop up menu and combo box) from a table.
    Supposing I have a table Customer(cust_id,cust_name)
    and now I want to populate it in such a manner that I can update the data back to the database and also access the list on the form.

    This is the method i am using to populate a list.
    1- First of all you need to create a non-database list item for customer_name.
    2-create this procedure
    PROCEDURE populate_list_with_query
    --Populates the given list item with the specified query.
    (p_list_item in VARCHAR2
    ,p_query in VARCHAR2)
    IS
    /* Name the record group after the list item (no
    block prefix). */
    cst_rg_name constant VARCHAR2(30) :=
    GET_ITEM_PROPERTY(p_list_item,item_name);
    v_rg_id RECORDGROUP;
    BEGIN
    v_rg_id := FIND_GROUP(cst_rg_name);
    IF ID_NULL(v_rg_id) THEN
    v_rg_id := CREATE_GROUP_FROM_QUERY(cst_rg_name,p_query);
    END IF;
    IF POPULATE_GROUP(v_rg_id) = 0 THEN
    POPULATE_LIST(p_list_item,v_rg_id);
    /* Force display of first list element label
    in the list item. */
    COPY(GET_LIST_ELEMENT_VALUE(p_list_item,1),p_list_item);
    END IF;
    END populate_list_with_query;
    3- Create When-Create-Record on the block level and write this code
    BEGIN
    POPULATE_LIST_WITH_QUERY('bk1.customer_name',
    'SELECT customer_name, to_char(customer_id) FROM customer');
    END;
    In this example, the customer name is the (visible) list label and the customer ID is the (actual) list value
    i hope this will solve your problem ...

  • How to make list item as text item  in oracle forms 6i

    Hello all,
    I created one form with one list item named "Country".. This list item shows country name for the particular employee in the employee table.I created this list item as database field. In the enter query mode i search an employee , This should act as item text.. Suppose i want to add an employee in enter query mode then i fill all the necessary fields,and
    when i click "country" list item it should display all the country names from "country_tab" table..So based on the situation
    this should act as list item and item text.. Can i Do this ?.. Pls help me.

    hai Andreas Weiden,
    I simply explain my requirement:
    I want to insert data and quering data by using single form...So, I created one form with data block. This form created from employee table.I have one text item in this form named country.This is database item.
    Ok ,Now the actual problem comes.I press "Enter query" in tools menu,Then enter one employee number in employee_no field.after i press
    Execute query In tools menu. It shows all the details corresponding to that employee..
    Note: here "country" text item also shows employees country.
    Right, Now i have another requirement. In the same form I want to insert a new employee. For that
    I planed to changes country text to list item [ because when  insert i can easily pick up one country .it
    reduces typing work ] . I have another table "COUNTRY". Using this table, i should populate country list item..
    So, the country item should act as both text item [When quering] as well as list item [ When inserting ]
    Is there any idea ti do this ?
    If this not possible then what is the alternative ?
    Pls suggest me..

  • How to create list items with multiple attachment files using rest api javascript

    In one of user form I am using javascript rest api to create a list item with multiple attachment files. So far I am able to create list item and once created uploading an attachment file. But this is two step process first create an item and then upload
    a file.
    It create an additional version of the item which is not desired. Also I am not able find a way to attach multiple files in a go. Following is the code I am using.
    createitem.executeAsync({
                    url: "/_api/web/lists/GetByTitle('UserForm')/items(1)/AttachmentFiles/add(FileName='" + aFile.name + "')",
                    method: "POST",
                    contentType: "application/json;odata=verbose",
                    headers: {
                        "Accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val()
                    binaryStringRequestBody: true,
                    body: fileContent,
                    success: fnsuccess,
                    error: fnerror
    So somehow I need to combine item attributes along with attachment files in body: param. I visited https://msdn.microsoft.com/en-us/library/office/dn531433.aspx#bk_ListItem but no success.
    Appreciate any help.

    Thanks Mahesh for the reply and post you share it was useful.
    But this does not solve the core of the issue. You are uploading attachments after creation of item and multiple files are being attached in loop. This is kind of iterative update to an existing item with attachments. This will end up creating multiple versions. 
    What I am trying to achieve is to create an item along with multiple attachments in a go. No item updates further to attach a file.
    Please suggest how this can be done in one go. SharePoint does it when one creates an item with multiple attachment.
    Thanks for your reply.

  • How to report all items in a folder, including subfolders?

    I've got a folder structure like this:
    Examples
    Product1
    Ver1_0
    Ver1_2
    Product2
    ver5_5
    Ver6_0
    How do I generate a Report that lists all items in a certain
    subfolder, including all subfolders?
    For instance how to list all items in the Examples folder and
    below (e.g all items), or how to list all items for the
    folder /Examples/Product1 and below?
    I need to provide a read-only view of the items in a report etc
    for one user-group. There might be a better way than a
    report...!?

    The spaces in the folder structure got stripped off...
    Trying to show it by prepending >'s instead of spaces to show
    the hierarchy:
    Examples
    Product1
    Ver1_0
    Ver1_2Product2
    Ver5_5
    Ver6_0
    (I hope u get it)

  • How to Copy list item attachment to document library in SharePoint 2010

    Hi,
    How to Create a folder ("List Item - Title Name") in Document library and copy list items Attachments to the same folder in SharePoint 2010,thanks in advance.
    Regards,
    Selvan.J
    Selvan J

    Hi,
    You should first check whether the folder exists in the library, if the folder not exists, then create it.
    I had modified the code, you can use the following code snippet to achieve it.
    private void EventCopyFileWhenItemCreatedOrUpdated(SPItemEventProperties properties)
    SPSite site = new SPSite(http://YourSiteName);
    SPWeb web = site.OpenWeb();
    SPList doclibList=properties.Web.Lists["YourLibName"];
    bool foundFolder = false;
    if (doclibList.Folders.Count>0)
    foreach (SPListItem fitem in doclibList.Folders)
    if (fitem.Title.Equals("FolderA"))
    foundFolder = true;
    break;
    if (foundFolder == false)
    SPListItem folder = doclibList.Folders.Add(doclibList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder,"FolderA");
    folder.Update();
    string fUrl = doclibList.RootFolder.ServerRelativeUrl+"/FolderA";
    SPFolder myLibrary = web.GetFolder(fUrl);
    if (properties.ListTitle == "YourListName")
    SPListItem sourceItem = properties.ListItem;
    properties.Web.AllowUnsafeUpdates = true;
    //get the folder with the attachments for the source item
    SPFolder sourceItemAttachmentsFolder =
    sourceItem.Web.Folders["Lists"].SubFolders[sourceItem.ParentList.Title].SubFolders["Attachments"].SubFolders[sourceItem.ID.ToString()];
    //Loop over the attachments, and add them to the target item
    foreach (SPFile file in sourceItemAttachmentsFolder.Files)
    if (CheckFileNameExist(file.Name , properties) == false)
    byte[] binFile = file.OpenBinary();
    myLibrary.Files.Add(System.IO.Path.GetFileName(file.Url) , binFile);
    private bool CheckFileNameExist(string fileNameInFileAttach, SPItemEventProperties properties)
    bool flag = false;
    SPList myDocumentLib = properties.Web.Lists["YourLibName"];
    SPQuery spQuery = new SPQuery();
    SPListItemCollection items = myDocumentLib.GetItems(spQuery);
    foreach (SPListItem item in items)
    if (fileNameInFileAttach == item["Name"].ToString())
    flag = true;
    break;
    return flag;
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • How to show list items in html page design?

    Hi all,
    I have a SharePoint list with column Title, Logo, Project Summary, Project Description and would like to show list items in html table design like:
    How to achieve this? thanks in advance!

    As per my understanding, You want to just redesign your list form. You can achieve the same using SPD2010 or you can use jQuery also if you don't have rights for SPD customization.
    Create
    a custom list form using SharePoint Designer
    SharePoint
    form: present fields side-by-side
    Thanks.

Maybe you are looking for

  • Exporting OS X Mail from Mountain Lion to Snow Leopard

    After upgrading to Mountain Lion, I partitioned my iMac HD to have two partitions: Macintosh HD has Mountain Lion; I reinstalled Snow Leopard on Macintosh HD 2. Best part: you can access your user-created files from EITHER disk partition. But not so

  • Using text in QT Pro

    I want to create floating text blocks as commentaries that will appear at various locations over a moving image (already in MOV format). I've found where I can do it using cartoon diolog bubbles, but that's not what I want. Is this possible, and if s

  • Skype contact showing online when offline?

    One of my contacts is being shown online but in reality they are offline. How is this even possible and is there a way to fix it? I'm running the newest version of Skype and I've tried re-installing it many times but it just keeps doing the same thin

  • Business process step for BW

    Dear friends,    I wants to generate business blueprint for BW implementation through sol Man 4.0. In t.code SOLAR01,i want to maintain structure under Business process level. But could not find any suitable process related to BW. I am getting only p

  • F:convertNumber min/maxFractionDigits as EL not working

    Hi, I've got some code wherre it appears that the f:convertNumber tag is igvnoring the minFractionDigits and maxFractionDigits: <h:inputText value="#{contributedAmount.amount}" styleClass="formInput input_40 required" required="true"> <f:convertNumbe