Interview Questions administrator

Best SharePoint administrator Interview Questions and Answers with topic wise:


Recycle Bin | MMS | ManagedVsCrawledProperties |

Monday, December 26, 2016

Move documents along with versioning

Keep in mind that below approach works only within the site collection level.  I mean to say here is it is not possible to move the documents between libraries across site collection levels.

The best approach to move the documents between the libraries along with versioning is using “site content structure” option. 

Note: But one thing we should keep in mind that versioning shoould be enabled in both the source and destination document libraries.

Steps to move the documents between document libraries:

Step1: Go to Site Actions -> Site Settings.  Under “Site Administration” click “Content and structure”

Step2: Find the source library and select the all or any specific documents you want to move and then click “Actions”à Move.

That’s it. Now, go and visit the destination document library. You will get the moved documents along with its versioning’s.

One thing I observed here is, along with the documents versioning, metadata also would came.
I have a created a source document library and created 3 custom columns with different types. Uploaded the new document along with the metadata and then moved this document to destination library.

In addition to the versioning in destination library  what ever the columns available in source got created the same in destination( means 3 custom columns which are all created by me on source library are also available in destination library).

Source library:


Destination library:



Happy Sharepoint.

Please take a momenet and do comments if this post really helps

Get sharepoint Host Web Url using REST

Just do copy paste the below code and execute it.


Note: The below shared code is 100% verified/executed.


Appmanifest.xml:

Set read level permisisons to the web

Default.aspx:

The host web title is: <label id="HostwebTitle"></label>

app.js:

var hostweburl;
var appweburl;

// Load the required SharePoint libraries
$(document).ready(function () {
    appweburl = window.location.protocol + "//" + window.location.host + _spPageContextInfo.webServerRelativeUrl;
    hostweburl = _spPageContextInfo.siteAbsoluteUrl;

    // resources are in URLs in the form:
    // web_url/_layouts/15/resource
    var scriptbase = hostweburl + "/_layouts/15/";

    // Load the js file and continue to the
    //   success event handler
    //$.getScript(scriptbase + "SP.RequestExecutor.js", execCrossDomainRequest);
    $.getScript(scriptbase + "SP.js", execCrossDomainRequest);
});

// Function to prepare and issue the request to get
//  SharePoint data
function execCrossDomainRequest() {
    var executor;

    // Initialize the RequestExecutor with the app web URL.
    executor = new SP.RequestExecutor(appweburl);

    // Issue the call against the host web.
    // To get the title using REST we can hit the endpoint:
    //      app_web_url/_api/SP.AppContextSite(@target)/web/title?@target='siteUrl'
    // The response formats the data in the JSON format.
    // The functions successHandler and errorHandler attend the
    //      success and error events respectively.
    executor.executeAsync(
        {
            url:
                appweburl +
                "/_api/SP.AppContextSite(@target)/web/title?@target='" +
                hostweburl + "'",
            method: "GET",
            headers: { "Accept": "application/json; odata=verbose" },
            success: successHandler,
            error: errorHandler
        }
    );
}

// Function to handle the success event.
// Prints the host web's title to the page.
function successHandler(data) {
    var jsonObject = JSON.parse(data.body);


    document.getElementById("HostwebTitle").innerHTML =
        "<b>" + jsonObject.d.Title + "</b>";
}

// Function to handle the error event.
// Prints the error message to the page.
function errorHandler(data, errorCode, errorMessage) {
    document.getElementById("HostwebTitle").innerText =
        "Could not complete cross-domain call: " + errorMessage;
}

// Function to retrieve a query string value.
// For production purposes you may want to use
//  a library to handle the query string.
function getQueryStringParameter(paramToRetrieve) {
    var params =
        document.URL.split("?")[1].split("&");
    var strParams = "";
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split("=");
        if (singleParam[0] == paramToRetrieve)
            return singleParam[1];
    }
}

Thanks for visting.. Happy Sharepoint

Please take a moment and do comments on it if its really helped you.