Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<script src="//code.jquery.com/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.01/jquery.SPServices.min.js" type="text/javascript"></script>
<script type="text/javascript">
var count;
var itemId;
$(document).ready( function () {
var numStr;
$().SPServices({
operation: "GetListItems",
async: false,
listName: "counter",
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each( function () {
itemId= $(this).attr("ows_ID");
count = Number($(this).attr("ows_Title"));
});
}
});
count++;
numStr = "CustomID - " + ("0000000" + count).slice(-8);
$("input[title='CustomID']").val(numStr).attr("readonly", "readonly").css("color", "#6a6a6a");
$(":text:not([readonly])").eq(0).focus();
});
function PreSaveAction(){
$().SPServices({
operation: "UpdateListItems",
async: false,
batchCmd: "Update",
listName: "counter",
valuepairs: [["Title", count]],
ID: itemId,
completefunc: function(xData, Status) {
}
});
return true;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.