View the versions of document from share point document library using code.

HI
i want to develop a web application (asp.net) from
1) users will browse and view documents saved in document library by passing a documents DocumentID as parameter 
to  sharepoint 2010 web application.
2)also that  document has versions and how users  will view required versions, if user  will upload document to document library
it will create new version and if user will same document with same name it over-right as new version.
and how user will view the old version 
adil

Replay:
From your description, my understanding is that you want to develop a web application to view document history versions of SharePoint 2010.
You could accomplish your requirement by using Client Object Model, please refer to this article:
https://msdn.microsoft.com/en-us/library/office/ee857094(v=office.14).aspx.
You could refer to this code below:
namespace clientOM
class Program
static void Main(string[] args)
ClientContext clientContext = new ClientContext("siteUrl");
Web site = clientContext.Web;
clientContext.Load(site);
List list = site.Lists.GetByTitle("Documents");
clientContext.Load(list);
clientContext.ExecuteQuery();
CamlQuery query = new CamlQuery();
query.ViewXml = "<View/>";
ListItemCollection allContacts = list.GetItems(query);
clientContext.Load(allContacts);
clientContext.ExecuteQuery();
FileCollection allFile = list.RootFolder.Files;
clientContext.Load(allFile);
clientContext.ExecuteQuery();
foreach (File file in allFile)
string version = file.UIVersionLabel;
FileVersionCollection versions = file.Versions;
clientContext.Load(versions);
clientContext.ExecuteQuery();
foreach (FileVersion hisVersion in versions)
string hisversion = hisVersion.VersionLabel;
Best Regards
Vincent Han
TechNet Community Support

Similar Messages

  • How top Open a Excel Document from share point document library using jquery

    How top Open a Excel Document  from share point document library using jquery

    Hi,
    According to your post, my understanding is that you want to open excel file via JQuery.
    To open excel file, we can use the following code.
    <script type="text/javascript">
    function openExcel(strFilePath) {
    var yourSite = "http://www.yoursite.com";
    openExcelDocPath(yourSite + strFilePath, false);
    function openExcelDocPath(strLocation, boolReadOnly) {
    var objExcel;
    objExcel = new ActiveXObject("Excel.Application");
    objExcel.Visible = true;
    objExcel.Workbooks.Open(strLocation, false, boolReadOnly);
    </script>
    For more reference:
    http://www.kavoir.com/2009/01/using-javascript-to-open-excel-and-word-files-in-html.html
    http://www.dotnetspider.com/resources/43453-Open-Word-Excel-files-using-Javascript.aspx
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Import Scenario from BPR - how to view the Version after import

    On SOLAR01 when you import scenarios from the BPR, how can you view the version of the Products that were imported? Sometimes in the BPR there are several versions available to import for a particular product.
    Once you have imported those business processes, how can you see the version that is tied to the one you imported?

    Helmut,
    If you don't have access to the server console, it might be possible to 'trick' tp into working from a workstation, but I wouldn't bet on it. You'd have to fake up a profile for it. I haven't tried this.
    Peering into the contents of a delivered transport file would be something that your Basis team would typically do. My suggestion is to work with them, either to use tp command-line option from the server console, or if that's not reasonable, then yes, go ahead and add it to the import queue of one of your sandbox systems. You can always delete it from the queue again later. If you don't actually import it, it isn't going to hurt anything.
    To do any of these options is going to require some level of filesystem access to your transport host, as you need to copy the two files that make up the transport there. You need to put the 'K' file into \usr\sap\trans\cofiles and the 'R' file into \usr\sap\trans\data. Then, you can either use the tp command-line tool, or you can go into STMS, go into the import queue of any system in the transport domain (so a sandbox is fine), and use Extras... Other Requests... Add and type in the transport request ID. Yes, this adds some entries about the transport into a few tables, but it doesn't actually import the transport, and it doesn't change anything about your system. It just allows the transport to show up as importable in the queue, and that will make it so that you can read the object list of the transport. Then, if you decide not to import it, you can delete it from the queue, and your system is back to the way it was before. Also, doing this will not put the transport into any other system's queue. Even if you import the transport (into a sandbox system), it won't show up in any other system's queue until you forward it.
    Regards,
    Matt

  • Is it possible to insert a PDF directly(ie from Share Point) to email (Outlook) without saving it?

    Is it possible to insert a PDF directly(ie from Share Point) to email (Outlook) without saving it?
    I open several docs on Sharepoint that I need to send out immediately and waste a lot of time saving it to my computer and than opening an email and attaching it and than deleting the file bc I don't need it - its already on Sharepoint where I can access it. 

    I have the exact same problem.  I used to could do it without saving until I upgraded to a new version.  I cannot figure out how to send it without saving.

  • Download files from Shared Point document library using SSIS packages

    Dear All,
            Can you please help me on how can I download excel/CSV files from share point document library to local machine using SSIS packages.
    Regads,
    Praveen C
    Regards, Praveen

    Hi Praveen,
    You can also implement
    custom component or try third party custom component such as SharePoint List Adapters:
    https://sqlsrvintegrationsrv.codeplex.com/releases/view/17652
    Regards,
    Mike Yin
    TechNet Community Support

  • 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

  • Use of KM services and TREX Search Engine From share point portal

    Hi All,
    We would like to  Use of KM services and TREX Search Engine From share point portal.
    For this purpose we interoperability between windows sharepoint and SAP Portal.
    Please provide necessary documents or suggestions for interoperability for above requirement.
    mail id : <b>[email protected]</b>
    Thanks in advance
    Regards
    Swarna B

    Hi,
    See this this links:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9e891378-0601-0010-5386-a3387f1b161b
    Regards,
    Senthil K.

  • Table to view the CO settlement document (not tcode)

    What is the table to view the CO settlement document.I donot need transaction code..only table pls.

    Hi,
    Please check the following tables.
    AUAA Settlement Document: Receiver Seg
    AUAB Settlement Document: Distribution
    AUAI  Settlement Rules per Depreciation
    AUAK Document Header for Settlement   
    AUAV Document Segment: Transactions
    COBRA Settlement Rule for Order Settlem
    I hope this will solve your purpose
    Regards,
    Jigar

  • Can you tell the version of iPad from the model #?

    Can you tell the version of iPad from the model #?  If so, what is model MD329LL ?

    Identify iPad Models...
    http://support.apple.com/kb/HT5452

  • SAP Trans.Code-To view the all expenses received from the company.

    Is there any SAP transaction code,to view the all expenses received from the company?For an example,I have received conveyance,medical,LTA etc.on vouchers.Now,I want to see the received on which date I have taken.
    Regards

    I guess this information you will get in following reports ( put appropriate cost center )
    Transaction Codes KSB1, KSB2, KSBP, KSB5
    Also check Accounting-> controllong-> Cost center accounting-> Info system-> Reports for cost center accounting-> line items/more reports.

  • Will installing a CS5 trial fix the version cue errors from CS4?

    Hi, I was wondering if installing a trial version of CS5 would fix the version cue errors from CS4.
    If not, does anyone know a good download of the version cue files? They have all dissappeared from my computer after running the cleanup script and the problem still persists =(

    Afterr months of pain and one ephiphany later, i have a simple solution to the issue.
    Go into the common files, adobe drive, version cue folder, and drag the files into the recycling bin =)
    So theres no need to install cs5 =D
    Hope this can help others who still have this issue.

  • To Generate the invoices (billing document) in t-code VF02 to DIRs in DMS

    Hi All,
    I have requirement is to generate the invoices (billing document) in t-code VF02 to DIRs in DMS or print list using ArchiveLink every night in batch program.
    Did anybody worked on similar scenerios, please let me know.
    Regards
    MM

    Hi Manish (and everyone).
    Were you able to find the solution to this?
    I am in a similar situation - trying to generate invoices from an ArchiveLink document.
    All setup pertaining to ArchiveLink is already in place.  What I need to do now is access the document from the content repository and start from there.
    Any input will be greatly appreciated.
    And of course, points will be rewarded.
    Many thanks!

  • 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

  • I just downloaded Ilife 9 and now my Iphoto doesn't open. The error message says: You cannot open your library using this version. Quit and use the older version. What can I do?

    I just downloaded Ilife 9 and now my Iphoto doesn't open. The error message says: You cannot open your library using this version. Quit and use the older version. What can I do?

    iLife '09 is not available as a download - it is only available as a purchase
    iLife '11 is available as a DVD purchase and the compoments of it are available from the App Store (iPhoto '11 (version 9.1.5), etc)
    Exactly what did you do? And exactly what does the error message say?
    On the surface it appears that you are attemptying to open a new library with an older version (iPhoto '09 can not open an iPhoto '11 library for example)
    LN

  • 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

Maybe you are looking for

  • After kernel 2.6.27, X does not start

    Hi guys! Since I made the much awaited (and sometimes dreaded) pacman -Syu, the latest kernel was installed. Then, I updated ndiswrapper to the latest version (1.53) and catalyst (I actually downgraded that one from 8.9 to 8.8). I then rebooted and d

  • OSA issues

    hi, i have configured the OSA template , in the top level of the template i have selected all the available enhancements for the template , but im not able to see all of the enhancement in the further template behaviour , how do i get to see all the

  • Mac air won't shut down

    Hi, my mac air suddenly for the first time ever , won't close down.  I have a feeling I have opened a dodgy email  but not sure, it is from a contact but could be hacked? On my pc I would use ctl +alt+del to bring up task manager to close dow the pc,

  • Abap code :replace the bank values of Dataefield to 20990101

    Please correct my abap code I am just trying to replace the bank values of Dataefield to 20990101 but i am getting the error invalid dataformat '00000000 '. Please correct my IF statement so that I can get this resolved IF SOURCE_FIELDS-DATETO = '000

  • Help help! Domain Name

    Hi Guys I'm soooo new to this. But I have this pressing question. If I subscribe to .mac for my family, will my kids be able to use their own domain names (which we just purchased for them) for their .mac page? We don't have a hosting service for the