Created
April 15, 2016 05:26
-
-
Save reshmee011/7d925ac9e42a4751930a8dceae5c2119 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script> | |
<script type="text/javascript" src="/_layouts/15/sp.js"></script> | |
<script type="text/javascript"> | |
//declare namespace | |
var ConfigureSiteSettings = ConfigureSiteSettings || {}; | |
// use sp utility to Get field values, need to find out how it will work with Nintex forms | |
//var myRichTextValue = getFieldValue('SiteCollectionURL'); | |
//alert(myRichTextValue); | |
ConfigureSiteSettings.UpdateDocIdSettings = (function() | |
{ | |
var siteUrl = document.getElementById("SiteUrl").value | |
var docIDPrefix = document.getElementById("docIDPrefix").value | |
if(!!siteUrl && !!docIDPrefix ) | |
{ | |
var clientContext = new SP.ClientContext(siteUrl); | |
oWebsite = clientContext.get_web(); | |
clientContext.load(oWebsite); | |
clientContext.executeQueryAsync( | |
Function.createDelegate(this, onQuerySucceeded), | |
Function.createDelegate(this, onQueryFailed) | |
); | |
function onQuerySucceeded(sender, args) { | |
alert('Title: ' + oWebsite.get_title() + | |
' Description: ' + oWebsite.get_description()); | |
var webProperties = oWebsite.get_allProperties(); | |
clientContext.load(webProperties); | |
var docIdValue = '<?xml version="1.0" encoding="utf-16"?><DocIdUiSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Prefix>' + docIDPrefix + '</Prefix> <AssignmentEnabled>true</AssignmentEnabled></DocIdUiSettings>' | |
webProperties.set_item("docid_settings_ui", docIdValue); | |
oWebsite.update(); | |
clientContext.executeQueryAsync(TaggedSuccess, TaggedFail); | |
} | |
function onQueryFailed(sender, args) { | |
alert('Request failed. ' + args.get_message() + | |
'\n' + args.get_stackTrace()); | |
} | |
function TaggedSuccess(sender, args) { | |
alert("Tagged your site."); | |
} | |
function TaggedFail(sender, args) { | |
alert("Tagging failed" + args.get_message()); | |
} | |
} | |
else | |
{ | |
alert("Enter Site Url and doc prefix"); | |
} | |
}); | |
</script> | |
<div> | |
<p> | |
<b>Configure Document Id Settings</b> | |
<br /> | |
<label>Site Collection URL<label><input type="text" value="" id="SiteUrl" /> | |
<label>Doc ID Prefix<label><input type="text" value="" id="docIDPrefix" /> | |
<button id="configureSiteDocIdSettings" onclick="ConfigureSiteSettings.UpdateDocIdSettings()">Configure Doc Id Settings</button> | |
</p> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment