C#/REST Getting files in a document library using Internal Name

Hi Folks,
I need to get a list of files in a SP2010 and SP2013 document library using the REST API - this is occurring inside a timer service application so am using C#.  As a constraint I need to use the internal names for the document libraries - primarily
because users tend to change the display name and this is an automated service.
When I make a call to _api/web/GetFolderByServerRealitveUrl('/Shared Documents')/Files  I get a bunch of XML but how do I get just a list of filename+ext.   I am using Xdocument (LINQ to XML). I need to retrieve the name property in the
contents sub element for all files returned.
Second question, how to I change this to use the internal name '/Document' instead of '/Shared Document', so that it copes with users changing the display name of document libraries.
Regards
Andy

Hi Andy,
1.For your issue, you can refer to the code as below:
using System.Xml;
namespace REST_XML_LIST_GET
class Program
static XmlNamespaceManager xmlnspm = new XmlNamespaceManager(new NameTable());
static Uri sharepointUrl = new Uri("Site URL/");
static void Main(string[] args)
xmlnspm.AddNamespace("atom", "http://www.w3.org/2005/Atom");
xmlnspm.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
xmlnspm.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
NetworkCredential cred = new System.Net.NetworkCredential("username", password", "domain");
HttpWebRequest listRequest = (HttpWebRequest)HttpWebRequest.Create(sharepointUrl.ToString() + "_api/Web/lists/getByTitle('List Name')/items");
listRequest.Method = "GET";
listRequest.Accept = "application/atom+xml";
listRequest.ContentType = "application/atom+xml;type=entry";
listRequest.Credentials = cred;
HttpWebResponse listResponse = (HttpWebResponse)listRequest.GetResponse();
StreamReader listReader = new StreamReader(listResponse.GetResponseStream());
var listXml = new XmlDocument();
listXml.LoadXml(listReader.ReadToEnd());
//Method 1 Seperate node list
var titleList = listXml.SelectNodes("//atom:entry/atom:content/m:properties/d:Title", xmlnspm);
var idList = listXml.SelectNodes("//atom:entry/atom:content/m:properties/d:ID", xmlnspm);
int i = 0;
foreach (XmlNode title in titleList)
Console.WriteLine(title.InnerXml+" "+idList[i++].InnerXml);
//Method 2 single node list
var prop = listXml.SelectNodes("//atom:entry/atom:content/m:properties", xmlnspm);
foreach (XmlNode ndlist in prop)
Console.WriteLine(ndlist.SelectSingleNode("d:Title", xmlnspm).InnerXml + " " + ndlist.SelectSingleNode("d:ID", xmlnspm).InnerXml);
Console.ReadLine();
2. For a workaround, you can get the display name based on the internal name and use the display name in the Rest API.
Reference:
http://www.c-sharpcorner.com/UploadFile/Roji.Joy/working-with-sharepoint-2013-rest-api-in-a-C-Sharp-managed-code/
https://dlr2008.wordpress.com/2013/11/14/sharepoint-2013-rest-api-the-c-connection-part-4-document-libraries-folders-and-files/
Thanks,
Eric
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected].
Eric Tao
TechNet Community Support

Similar Messages

  • Download older version of a file from SharePoint Document Library using CSOM and 404 error

    Hi,
    I am trying to download previous versions including Major and Minor versions of documents from SharePoint Online using CSOM. I get 404 error when I try to download the file. I found several posts on various discussion forums where people are getting same
    error but none of those have any solution/answer. Below is one of the threads and sample code I have tried that results in 404 error. If I use the link in browser directly, I am able to download the file. Also I am able to download the current version of file
    using CSOM without any problem, it is only the older versions that give me 404 in CSOM.
    http://qandasys.info/how-to-download-the-historical-file-version-content-using-csom/
    public int GetStreamFromFile(string docid, string lib, string fileurl, ClientContext clientContext, int iuserid, string Version, bool isCurrrent)
    if(!isCurrent)
    List LibraryName = clientContext.Web.Lists.GetByTitle(lib);
    clientContext.Load(LibraryName);
    clientContext.ExecuteQuery();
    CamlQuery camlQuery = new CamlQuery();
    camlQuery.ViewXml = "" + fileurl +
    Microsoft.SharePoint.Client.ListItemCollection collListItem = LibraryName.GetItems(camlQuery);
    clientContext.Load(collListItem, items => items.Include(item => item.Id, item => item["FileLeafRef"], item => item["LinkFilename"],
    item => item["FileRef"], item => item["File_x0020_Size"], item => item["DocIcon"], item => item.File.Versions));
    //clientContext.Load(collListItem);
    clientContext.ExecuteQuery();
    foreach (Microsoft.SharePoint.Client.ListItem oListItem in collListItem)
    //string fileurl1 = (string)oListItem["FileRef"];
    //string filename = (string)oListItem["LinkFilename"];
    foreach (FileVersion version in oListItem.File.Versions)
    if (Version == version.VersionLabel)
    //Added excutequery to get object one more time as per blog
    //http://social.technet.microsoft.com/Forums/de-DE/sharepointdevelopmentprevious/thread/88a05256-8694-4e40-863d-6c77512e079b
    clientContext.ExecuteQuery();
    FileInformation fileInformation = ClientOM.File.OpenBinaryDirect(clientContext,version.Url);
    bytesarr = ReadFully(fileInformation.Stream);
    Darwaish

    Hi,
    According to your description,
    I know you want to get older version of a file from SharePoint Document Library using Client Object Model.
    The following code snippet for your reference:
    public void GetVersions()
    ClientContext clientContext = new ClientContext(“http://SPSite”);
    Web site = clientContext.Web;
    clientContext.Load(site);
    clientContext.ExecuteQuery();
    File file = site.GetFileByServerRelativeUrl(“/Shared Documents/mydocument.doc”);
    clientContext.Load(file);
    clientContext.ExecuteQuery();
    ListItem currentItem = file.ListItemAllFields;
    clientContext.Load(currentItem);
    clientContext.ExecuteQuery();
    FileVersionCollection versions = file.Versions;
    clientContext.Load(versions);
    clientContext.ExecuteQuery();
    if (versions != null)
    foreach(FileVersion _version in versions)
    Console.WriteLine(“Version : {0}”,_version.VersionLabel);
    More information:
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.file.versions.aspx
    Best Regards,
    Dennis Guo

  • Edit CSV files present in document library using Microsoft Excel

    Hi all
    I have a document library with CSV files uploaded. I have used the below mapping in DOCICON.xml present in \14\TEMPLATE\XML folder.
    <Mapping Key="csv" Value="csv16.gif" EditText="Microsoft Excel" OpenControl="SharePoint.OpenDocuments"/>
    And I modified mime type with "application/vnd.ms-excel" for csv in IIS7. Now, when i click on the file  popup is getting displayed with 2 Radio Buttons.
    1) Read Only
    2)Edit
    When i select "Read Only", the file is opening in Microsoft Excel in readonly mode But when i select "Edit", the file is opening in Note pad and its editable.
    Now, My requirement is to edit the csv file in Microsoft Excel not in NotPad.
    Can Any one help me to acheive this!! Thanks in advance.

    Try below:
    http://nickgrattan.wordpress.com/2011/01/05/sharepoint-opening-csv-files-with-microsoft-excel/
    Run the “Internet Information Services (IIS) Manager” application from the Start/Administrative tools menu.
    Select the server in the left-hand pane.
    Select “MIME Types” in the list of options in the middle pane.
    Then locate the .CSV entry (it should already exist) and change the MIME type to: application/vnd.ms-excel, and click
    OK.

  • Adding file in SharePoint document Library using sandbox solution

     Why I am Missing Uploaded File name In Post back & am unable to add debugger give me solution thanks in advance
    Below is my sample code
    protected void btnsubmit_Click1(object sender, EventArgs e)
                try
                            //upload Image
                            web.AllowUnsafeUpdates = true;
                            Boolean replaceexistingfile = true;
                            if (Filephoto.HasFile)
                                Stream fStream = Filephoto.PostedFile.InputStream;
                                byte[] contents = new byte[fStream.Length];
                                fStream.Read(contents, 0, (int)fStream.Length);
                                fStream.Close();
                                string FileName = Filephoto.FileName;
                                string destUrl = SPContext.Current.Web.Url + DocumentLibName + FileName;
                                 web.Files.Add(destUrl, contents, replaceexistingfile);
                                SPFile file = web.Lists[DocumentLibName].RootFolder.Files.Add(FileName, contents, replaceexistingfile);
                                lblliteral.Text = file.ToString();
                                SPFieldLookupValue value = new SPFieldLookupValue(listitem.ID, listitem["EmployeeCode"].ToString());
                                file.Item["EmployeeCode"] = value.ToString();
                                file.Item.Update();
                            else
                                //throw new FileNotFoundException("File Not Found");
                                string FileName = "nofile";
                                lblliteral.Text = FileName + "filepload" + FilePassport.FileName + " : " + FilePan.FileName;
                            web.AllowUnsafeUpdates = false;
                catch (Exception ex)
                  //  Page.Response.Write(ex.Message);
                    string FileName = ex.Message;
                    lblliteral.Text = FileName;
                                                            

    Hi,
    We can put into the Session, the code snippet for your reference:
    //If first time page is submitted and we have file in FileUpload control but not in session
    // Store the values to SEssion Object
    if (Session["FileUpload1"] == null && FileUpload1.HasFile)
    Session["FileUpload1"] = FileUpload1;
    Label1.Text = FileUpload1.FileName;
    // Next time submit and Session has values but FileUpload is Blank
    // Return the values from session to FileUpload
    else if (Session["FileUpload1"] != null && (! FileUpload1.HasFile))
    FileUpload1 = (FileUpload) Session["FileUpload1"];
    Label1.Text = FileUpload1.FileName;
    // Now there could be another sictution when Session has File but user want to change the file
    // In this case we have to change the file in session object
    else if (FileUpload1.HasFile)
    Session["FileUpload1"] = FileUpload1;
    Label1.Text = FileUpload1.FileName;
    More information about the similar issue:
    http://www.codeproject.com/Tips/101834/How-to-Maintain-FileUpload-Control-s-State-after-P
    If you want to upload file into document library, here is another option for your reference:
    http://purtuga.github.io/SPWidgets/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Cannot edit properties after overwriting file in a document library

    I am (programmatically) overwriting a file in a document library after which none of the metadata fields can be edited either programmatically or manually:
    Edit Properties -> change something -> Save
    There is no error, just none of the metadata fields will actually update. To overwrite the file, I am using copy.asmx webservice. I get the same result when overwriting via REST, or just doing a plain http PUT. I also tried list.asmx webservice to update metadata.
    As long as I don't overwrite a file, everything works great.
    This is Sharepoint 2010. Versioning is off, checkout is not required. "Overwriting" means there is an existing file, previously uploaded manually or with copyservice and the new file has the same name.
    Has anybody seen this behavior? (or managed to get a sharepoint document library file into a similar state).
    Thanks, RL

    Hi,
    According to your post, my understanding is that after uploading file using the Copy.asmx web service, you could not edit the properties.
    I had used the following code to upload the file, after that to edit the properties, it worked without any issue.
    static void Main(string[] args)
    Copy copy = new Copy();
    copy.Credentials = new System.Net.NetworkCredential("UserName","Password","Domain");
    copy.Url = "http://sp/_vti_bin/copy.asmx";
    string filePath = @"C:\Test\Edite2.txt";
    string[] destURL = { @"http://sp/LIbA/Edite2.txt" };
    FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
    byte[] contents = new byte [fs.Length];
    fs.Read(contents,0,Convert.ToInt32(fs.Length));
    fs.Close();
    FieldInformation fileFieldInfo = new FieldInformation();
    fileFieldInfo.DisplayName = "Edite2";
    fileFieldInfo.Value = "Edite2";
    fileFieldInfo.InternalName = "Edite2";
    fileFieldInfo.Type = sp.FieldType.Text;
    FieldInformation[] fileFieldInfoArray = { fileFieldInfo };
    CopyResult copyResult1 = new CopyResult();
    CopyResult copyResult2 = new CopyResult();
    CopyResult[] copyResultArray = { copyResult1,copyResult2};
    uint resultCopy = copy.CopyIntoItems(filePath,destURL,fileFieldInfoArray,contents,out copyResultArray);
    Console.WriteLine("Upload Successful...");
    Console.ReadKey();
    You can check with the above code, then check whether it works.
    Did the issue occur in other libraries?
    You can create new library to check whether it works, maybe the library had been corrupted.
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Not able to copying files/folders from one Document Library to another Document Library using Open with Browser functionality

    Hi All, 
    We have SharePoint Production server 2013 where users are complaining that they are not able to copy or move files from one document library to another document library using “Open with Explorer” functionality.
    We tried to activate publishing features on production server but it did not work. We users reported following errors:  
    Copying files from one document library to another document library:
    Tried to map the document libraries and still not get the error to copy files: 
    In our UAT environment we are able to copy and move folders from using “Open with Explorer” though.
    We have tried to simulate in the UAT environment but could not reproduce the production environment.  
    Any pointers about this issue would be highly appertained.
    Thanks in advance
    Regards,
    Aroh  
    Aroh Shukla

    Hi John and all,
    One the newly created web applications that we created few days back and navigated to document library, clicked on “Open with Explorer”, we get this error.
    We're having a problem opening this location in file explorer. Add this website to your trusted and try again.
    We added to the trusted site in Internet Explorer for this web application, cleared the cache and open the site with same document library but still get the same above error.
    However, another existing web application (In same the Farm) that we are troubleshooting at the moment, we are able click on “Open with Explorer”,  login in credentials opens and we entered the details we are able to open the document
    library and tried to follow these steps:
    From Windows Explorer (using with Open with Explorer), tried to copy or move a files to
    source document library.
    From Windows Explorer moved this file to another destination document library and we got this error.
    What we have to achieve is users should be able to copy files and folders using
    Open with Explorer functionality. We don’t know why Open with Explorer
    functionality not work working for our environment.  
    Are we doing something wrong? 
    We have referred to following websites.
    we hope concepts of copying / Moving files are similar as SharePoint 2010. Our production environment is SharePoint 2013.   
    http://www.mcstech.net/blog/index.cfm/2012/1/4/SharePoint-2010-Moving-Documents-Between-Libraries https://andreakalli.wordpress.com/2014/01/28/moving-or-copying-files-and-folders-in-sharepoint/
    Please advise us. Thank you.
    Regards,
    Aroh
    Aroh Shukla

  • Authentication prompt issue when opening an office file in a document library with read permission for domain users

    An user as part of the domain users tries to open an office file from a document library but he got an authentication prompt asking him to authenticate. Domain users has only access to this library and not to the whole site. This uses to work in SharePoint
    2007 without any problem but not in SharePoint 2013, we didn't have a workflow on SP2007.
    Domain users has read access to only this document library in the site, but he shouldn't get an authentication prompt since he is part of the domain users and he is not trying to modify the document, he can open the document but gets two prompts, he can't
    also see the list using explorer view since nothings appears using the explorer view.
    Now, when opening the file, we can see..Updating Workflow Status, but we don't have any workflow working on this site or library, event any feature related to workflow.
    If we go to the event viewer in the server, we find this information,
    I also checked this thread but I couldn't find this scenario.
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/91bc770b-bb70-4885-a4ad-a243edb88753/event-id-8026-workflow-soap-getworkflowdataforitem-failed-doc-library-no-workflow?forum=sharepointgeneralprevious
    I also created another list with the same permissions and using other office files but got the same behavior.
    Now, we have migrated this site from SP2007 to SP2013.
    Any ideas?

    OK, I am going to throw out a lot of ideas here so hopefully they get you closer to a diagnosis. Hang on :)
    Does it happen to work for some users but not others? If so, try logging in on the "good" computer with the "bad" username. This will tell you if the problem is related to the end-user's system. Also, once the user downloads a document
    successfully can they open and work on it in Word? Also, does the document library have any custom content types associated with it or does it just use 'Document'?
    I notice that there are other folks on the web that have run into this same problem and the similarity seems to be that they are either on SharePoint 2007 or have upgraded from 2007. Did this doc library start out as a 2007 library?
    What you might want to do is this: Make a site collection from scratch in 2013 (or find one that you know was created in 2013). Choose team site (or whatever you want) for the root web and set up the security the same way you have it on the malfunctioning
    library. Now, use windows explorer to copy and paste some of the documents to the new location. Be sure you recreate any needed content types. Now test it from the troubled user's computer.
    I'm thinking there may be something that is different about the library since it was migrated through various versions and updates since 2007. I've sometimes found that there can be problems (especially with user profiles but that's a different story) with
    things that go through this evolution.

  • How to Auto Check-in .pdf Files in a Document library(after Drag & Drop) - sharepoint 2013?

    Hi,
    Once I Drag and drop the .pdf documents in a document library files get
    checked out automatically.
    I want the files to be checked-in automatically once they are dragged and Dropped.
    Please note : I am able to do the above things with .doc (world files) but not with the
    .pdf files.
    I have provided all the default values. Tried all the below options Still no success :-( 
    Require Content Approval for submitted items ?    NO
    Create a version each time you edit a file in this document library ? No visioning
    Require documents to be check out before they can be edited? No
    Anyone Come across this issue.??
    Regards, 
    Pavan.

    Hi, 
    I found the problem(Not the solution).
    I have set the default values from Column default value settings,
    the default values are getting set to the columns but the file still in checked-out mode.
    If I put the defult values to Library columns directly/Site column directly , Its working fine. - We found this work-around. 
    But still the issue Exists why its not working when I set Default values from Column default value settings
    and try to drag and drop documents. :-( 

  • Document Set Creation in document library using REST API in Sharepoint 2013

    Hi,
    I want to create the document set using REST API call. Currently i am able to create the folder and able to upload the files using REST API's in the document library. Is there any way we can pass the contentype name or Id and create the document set using
    REST API call. We need to create the document set along with metadata and upload the files inside the document set.
    I need to create the document set along with meta data column values using REST API. Please let me know how we can achieve this through REST API.
    Thank you,
    Mylsamy

    Hi,
    According to your post, my understanding is that you wanted to create document set along with managed metadata fields.
    The REST API does not currently support working with Managed Metadata or Taxonomy fields.
    As a workaround, we can use the JavaScript Client Object Model.
    Create document set using JavaScript Client Object Model.
    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.technet.microsoft.com/Forums/sharepoint/en-US/aacd96dc-0fb2-4f0d-ab4c-f94ce819e3ed/create-document-sets-with-javascript-com-sharepoint-2010
    Set managed metadata field with JavaScript Client Object Model.
    http://sharepoint.stackexchange.com/questions/95933/add-list-item-with-managed-metadata-field-through-jsom
    http://sharepointfieldnotes.blogspot.com/2013/06/sharepoint-2013-code-tips-setting.html
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Having trouble opening Crystal Report files from a document library

    I am trying to open Crystal Report .rpt files from a document library in either the native, client Crystal Reports software or in Crystal Reports Viewer. When I add the Crystal Report files to a document library and attempt to open them SharePoint displays
    a prompt asking me to save the file locally instead of opening the file. I have done a lot of research online and found several sites discussing similar scenarios, however, I have not been able to get these solutions to work. Here is a short list of sites
    I have referenced for possible solutions:
    http://naadydev.blogspot.com/2013/03/crystal-report-viewer-sharepoint-2010.html?showComment=1383339860122
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/52aabf2d-10dc-424c-bd50-124fc972a9b9/crystal-report-viewer-integration-with-sharepoint-2010?forum=sharepointgeneralprevious
    http://www.codeproject.com/Articles/42731/Crystal-Reports-WebPart-for-SharePoint
    Here are the steps I have done to try to get the .rpt files to open:
    Added the Crystal Report extension .rpt as a MIME type
    Installed the Visual Studio 2012 Crystal Reports Viewer toolbar
    Installed the 64-bit Crystal Reports runtime
    I have also created a solution file based off the Code Project site which partially works, but not quite right. In this project I have created a document library called "Crystal Reports rpt Files" and deployed the solution file to a site. When
    I open the Web Part Maintenance Toolbar I can see the selected .rpt file in the drop-down, but no Crystal Report file is displayed on the page itself.
    I am not sure what I am doing wrong. Does anyone have experience working with Crystal Reports and SharePoint 2013 (or earlier versions) that could lend some advice?
    Thank you,
    Alex

    We are having the exact same issue, has anyone resolved this yet?

  • How to update managed metadata column for all file in document library using powershell

    Hi,
    How to update managed metadata column for all file in document library using powershell?
    Any help on it.
    Thanks & REgards
    Poomani Sankaran

    Hi TanPart,
    I have changed the code which you have give in order to get the files from SharePoint 2010 Foundation  Document Library.But i am getting below error in powershell.
    Property 'ListItemCollectionPosition' cannot be found on this object; make sure it exists and is settable.
    Could you tell me which is the issues in it?
    See the code below.
    $web = Get-SPWeb http://ntmoss2010:9090/Site
    $list = $web.Lists["DocLib"]
    $query = New-Object Microsoft.SharePoint.SPQuery
    $query.ViewAttributes = "Scope='Recursive'";
    $query.RowLimit = 2000
    $caml = '<Where><Contains><FieldRef Name="Title" /><Value Type="Text">Process Documents/Delivery</Value></Contains></Where>' +
            '<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>'
    $query.Query = $caml
    do
        $listItems = $list.GetItems($query)
        $spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
        foreach($item in $listItems)
            #Cast to SPListItem to avoid ambiguous overload error
            $spItem = [Microsoft.SharePoint.SPListItem]$item;
            Write-Host $spItem.Title       
    while ($spQuery.ListItemCollectionPosition -ne $null)
    Thanks & Regards
    Poomani Sankaran

  • Get/retreive managed metadata column value from Document Library using SharePoint 2013 JSOM

    Hi,
    I am trying to retrieve managed metadata column (NewsCategory) value in SharePoint 2013 Document library using JSOM.
    I get "Object Object" rather than actual value.
    I tried:-
    var newsCat = item.get_item('NewsCategory');
    alert(newsCat) //Displays [Object Object]
    var newsCatLabel = newsCat.get_label();
    var newsCatId = newsCat.get_termGuid();
    But, I get the error "Object doesn't support property or method get_label()"
    I also tried :-
    var newsTags = item.get_item(' NewsCategory ');
    for (var i = 0; i < newsTags.get_count() ; i++) {
    var newsTag = newsTags.getItemAtIndex(i);
    var newsTagLabel = newsTag.get_label();
    var newsTagId = newsTag.get_termGuid();
    Even now I get the error "Object doesn't support property or method get_count()"
    I have included " NewsCategory " in the load request:- context.load(items, 'Include(File, NewsCategory)');
    Any idea what the issue is? Do I have to add any *.js file using $.getScript?
    I added following .js files
    var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/";
    $.getScript(scriptbase + "SP.Runtime.js", function () {
    $.getScript(scriptbase + "SP.js", function () {
    $.getScript(scriptbase + "SP.Core.js", function () {
    Thanks in Advance,

    Hi Patrick,
    I already added those references. I just pasted the parts of script snippet in my initial post. To avoid confusion I am pasting here complete script.
    2.1.1.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
    var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/";
    $.getScript(scriptbase + "SP.Runtime.js", function () {
    $.getScript(scriptbase + "SP.js", function () {
    $.getScript(scriptbase + "SP.Core.js", function () {
    function getdata() {
    var context = new SP.ClientContext.get_current();
    var web = context.get_web();
    var list = web.get_lists().getByTitle('Documents');
    var camlQuery = new SP.CamlQuery();
    var filterCategory = 'Solutions';
    var IDfromTaxonomyHiddenList = 15;
    camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef LookupId="TRUE" Name="'+filterCategory+'" /><Value Type="ID">' + IDfromTaxonomyHiddenList +'</Value></Eq></Where></Query></View>');
    /*the above CAML query successfully gets all the list items matching the criteria including "NewsCategory" managed metadata column values
    But when I try to display the value it retrieved it ouputs/emits Object Object rather than actual values */
    var items = list.getItems(camlQuery);
    context.load(items, 'Include(File,NewsCategory)');
    context.executeQueryAsync(
    Function.createDelegate(this, function (sender, args) {
    if (items.get_count() > 0) {
    var listItemEnumerator = items.getEnumerator();
    while (listItemEnumerator.moveNext()) {
    var oListItem = listItemEnumerator.get_current();
    var file = oListItem.get_file();
    var name = file.get_name();
    var newsCat = oListItem.get_item('NewsCategory'); alert(newsTags.constructor.getName());
    alert(newsCat) //Displays [Object Object]
    var newsCatLabel = newsCat.get_label(); // Here it errors out with message "Object doesn't support property or method get_label()"
    var newsCatId = newsCat.get_termGuid();
    } //end while
    }//end if
    Function.createDelegate(this, function (sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    ExecuteOrDelayUntilScriptLoaded(getdata, "SP.Core.js");
    </script>
    In the above script "var name = file.get_name(); " gets the exact file name.
    But the line "var newsCat = item.get_item('NewsCategory');
           alert(newsCat) //Displays [Object Object]  rather than actual value.
    Issue resolved replace "oListItem.get_item('NewsCategory');" with oListItem.get_item('NewsCategory').get_label();"
    Thanks

  • File Open Issues - document library pdf file to open in new browser window

    Hi
    I have a requirement to open the document library containing pdf file to open in new browser window. So far I have tried following steps but could not get it to work.
    1. Changing Document library advance setting to open the document in browser (have tried others as well).
    2. SharePoint web application setting changed as Permissive instead of Strict. Here the pdf file opens in browser but redirect from document library instead of new window(Also tried adding Target=”_blank” and no change).
    3. Executed the powershell script to adding MIME type to see if it works but no change.
    $webApp = Get-SPWebApplication http://SharePointSite
    If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains "application/pdf")
    Write-Host -ForegroundColor White "Adding PDF MIME Type..."
    $webApp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
    $webApp.Update()
    Write-Host -ForegroundColor White "Added and saved."
    Else
    Write-Host -ForegroundColor White "PDF MIME type is already added."
    4. Open the Doc library and modified ALLItems.aspx to add Target= “_blank”
    5. I have already tried solutions suggested in the link:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9db08c4a-b53c-419a-84f8-001c194d1311/how-to-open-sharepoint-document-library-pdf-file-in-new-window?forum=sharepointadminlegacy
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/530e2ea1-d77d-491c-935f-04f536e439a5/open-a-pdf-document-to-a-new-browser-in-the-document-library-web-part?forum=sharepointadminlegacy
    http://mindsharpblogs.com/todd/archive/2005/08/16/654.html
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/7b6091df-4657-4799-ba02-259ebd7e4b7c/pdf-doesnt-open-in-document-library?forum=sharepointadminlegacy
    Appreciate if there are any working solution from any of you. Many Thanks

    I found a solution which works only in the development. No idea when I compared, Browser MIME type is enabled, STRICT browser type is configured for web application. on the document library advance setting, default to open in new browser. Both configurations
    are identical but I am able to open pdf file in new window in my developing using jquery script
    http://blog.ithinksharepoint.com/2011/02/21/open-pdf-files-from-a-document-library-in-a-new-window/ but the same does not work on production server :(
    Any help experts?
    Thanks

  • Unable to edit .vsdx visio file that is inside a document library using visio 2010 sp2

    I have Visio 2010 SP2 installed locally inside my machine. The current version can open vsdx files by doing some conversions. I got the following scenario inside my SharePoint server 2013:-
    Currently I have Visio file (with .vsdx extension) uploaded to my SharePoint 2013 document library.
    If I click on the Visio file I got the following dialog.
    I select “Edit”, click on ok.
    Then the visio 2010 application will convert the current file and open it locally inside my machine.
    But the opened file will have it name as “Copy (1) of ….”, as follow:-
    So if I do some changes to the Visio file and I click on save I will not be able to save my changes back to the SharePoint server’s document library. Now if I do the same steps for a .vsd file not .vsdx then I can directly open the Visio file (without any
    conversion process) and I will be able to save my changes back to SharePoint server.
    So can anyone advice how to be able to edit .vsdx files which are uploaded to SharePoint document library using visio 2010 SP2 ?
    Thanks

    Thank you for your ideas.
    After that last posting, but before your response, I asked them to add the local farm to their trusted sites zone. Several blogs I had encountered while searching had listed that as something they had tried.
    As soon as they added the site to their trusted site zone, the problems went away.
    It was definitely not all users - I only had 2 people directly contact me about the issue.
    I never got a chance to ask them about other SharePoint sites - they were working on the sites where they spent most of their time - I don't know if they had other sites.
    The old location and the new location of these 2 sites are in the same site collection - it was moving them from
    http://myfarm/sites/div/dept67/site1
    to
    http://myfarm/sites/div/dept64/site1
    basically (with the actual names changed to protect my job).
    The site collection is /sites/div . So the site collection features are the same.
    I suppose that the site features could have changed between the export and the import - but since things are working now and I didn't change any features, I don't think that it is.
    At this point, things appear to be working. However strange that seems to me.

  • Schedule the Publishing date of a file in Document Library using CSOM

    I am having a hard time to schedule the publishing date of a document uploaded to a sharepoint document library. Basicaly, what I want is to upload a file to a document library and to schedule it´s publishing for a future date, using CSOM. Then someone should
    approve this (file content and scheduled date and time for publishing).
    I am able to upload the document to the document library and to start the approval workflow automatically (when the document is uploaded), but I don´t know how to set the publishing date using client side object model.
    Apparently all I need to do is to set up the properties ScheduledItem.StartDate and ScheduledItem.EndDate, but I just can´t manage to do it. Any help will be very much appreciated.

    I am having a hard time to schedule the publishing date of a document uploaded to a sharepoint document library. Basicaly, what I want is to upload a file to a document library and to schedule it´s publishing for a future date, using CSOM. Then someone should
    approve this (file content and scheduled date and time for publishing).
    Scheduling is enable and the coluns StartDate and EndDate are already added to the document library. I am able to upload the document to the document library and to start the approval workflow automatically (when the document is uploaded), but I don´t know
    how to set the publishing date using client side object model.
    Apparently all I need to do is to set up the properties ScheduledItem.StartDate and ScheduledItem.EndDate, but I just can´t manage to do it. Any help will be very much appreciated.

Maybe you are looking for

  • Error in installing Oracle 11g R2

    Hi, after I unzipped the 2 files in one folder and the installation started it gave this error: file not found C:\app\product\11.2.0\dbhome_2\oc4j\j2ee\oc4j_applications\applications\em.ear and more files also cannot be found. please tell me what's t

  • How to upload data into form of Oracle EBS R12 using ATS ver 9.0

    Hi experts, Could you please guide me how to upload data into form on Oracle EBS R12 using Oracle Application Testing Suite verson 9.(The simpliest way) For example: I need to create user account on Oracle EBS. Normally, I use Dataloader to upload th

  • 2 column fixed behaving as elastic? and image reflowing

    Apologies if these 2 questions have been asked previously but I couldn't find the answer when I searched the forums today. I hope someone can help with 2 (probably simple) issues with my web site: I selected a fixed template when starting dreamweaver

  • Bonjour: Heard, not seen

    My wife and I use Bonjour as we work in separate rooms. I can hear that she sent me a message as Bonjour makes the normal sound, but there's nothing in the Bonjour window from her, although on her end she does see my texts, links, and whatever. Anyon

  • ActionListener on an Image

    I have a few Images moving around on a Canvas. The Images are of class Image I have 2 buttons, turn left and turn right which when clicked make one of the Images turn left or right. The buttons have actionListeners attached to them. How could I make