Hi
the problem is i need the value last ID which was created in the list, whether the item is deleted or not
whichever is the last id i need value if that as i am creating a sequential number using the ID
Below is my code
<html><head><script type="text/javascript"> ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js"); // Get the current Site var webAbsoluteUrl; function retrieveListItems() { webAbsoluteUrl= _spPageContextInfo.webAbsoluteUrl; if (_spPageContextInfo.serverRequestPath.endsWith("NewForm.aspx")) { var clientContext = new SP.ClientContext(webAbsoluteUrl); // Get the liste instance var oList = clientContext.get_web().get_lists().getByTitle('ABC'); var camlQuery = new SP.CamlQuery(); // Get only the last element camlQuery.set_viewXml('<Query><OrderBy><FieldRef Name=\'Title\' Ascending=\'False\' /></OrderBy></Query><RowLimit>1</RowLimit>'); collListItem = oList.getItems(camlQuery); clientContext.load(collListItem); clientContext.executeQueryAsync(onQuerySucceeded, onQueryFailed); } } function onQuerySucceeded(sender, args) { $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").attr("readonly", "true").css('background-color', '#fff', 'color', '#444'); $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").attr("disabled", "disabled"); var isdata=false; var listItemInfo=''; var listItemEnumerator = collListItem.getEnumerator(); while (listItemEnumerator.moveNext()) { isdata=true; var oListItem = listItemEnumerator.get_current(); listItemInfo = oListItem.get_item("ID"); // Split the first var res = listItemInfo; var newID1 = res+1; var newID = "ABC-00" + newID1 // create the new id if(isdata==true){ $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").val(newID); } } if(isdata==false){ $("input[id*='fa564e0f-0c70-4ab9-b863-0177e6ddd247']").val("ABC-00" + 1); } listItemInfo.toString(); } function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } _spBodyOnLoadFunctionNames.push("SetReadOnly()");</script></head></html>
Paru