<script src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js" type="text/javascript">
</script>
<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" src="/sites/site name here/SiteAssets/jquery-2.1.4.min.js"></script>
<script>
function updateListItem(siteUrl) {
var r = confirm("Are you sure you want to update doc status for this ID");
if (r == true) {
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('List name here');
var mDocID = document.getElementById("txtDocID").value;
var mDocStatusObj = document.getElementById("selStatus");
var mDocStatus = mDocStatusObj.options[mDocStatusObj.selectedIndex].text;
this.oListItem = oList.getItemById(mDocID);
oListItem.set_item('Status', mDocStatus);
oListItem.update();
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
} else {
alert("You have cancelled the document status update.");
}
}
function onQuerySucceeded() {
alert('Item updated!');
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}
</script>
<html>
<table>
<tr>
<td><b>Document Status Update Page</b></td>
</tr>
<tr>
<td>Please enter the Document ID to update : </td><td><input id="txtDocID" type="text"
width="30px"></td>
</tr>
<tr>
<td>Please select the status to update : </td>
<td>
<select id="selStatus">
<option>Actual</option>
<option>Archived</option>
</select>
<br>
</td>
</tr>
<tr><td>
<input type="button" value="Update Document Status" onclick="updateListItem
('URL here')" />
</td></tr>
</table>
</html>
No comments:
Post a Comment