Generate unique id in SharePoint using jQuery/JavaScript

Advertisement
In this article we are able to see how to generate unique id for each item, while creating an item, we are showing the Id in the NewForm.aspx
We are having text box with id “textbox1”, in the GenerateUniqueID method we are getting the Unique GUID as per our requirement we are adding the Prefix SP with six unique value with text and characters.

<html>
Unique ID:<input type="text" id="textbox1"/>
</html>

function GenerateUniqueID() {
uid = 'SP-' +'xxxxxx'.replace(/[xy]/g, function(c) {
var r = Math.random() * 16 | 0,
v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16).toUpperCase();
});
}
<script>
GenerateUniqueID;
$('#textbox1').val(uid);

</script>

Output:



SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM
Advertisements
SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a comment