Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Referencing and Modifying ListID in Edit Form

$
0
0
Hi there,

I have a simple script that I am using locally to generate unique Project IDs for numerous projects throughout our department. I want to move this script into SharePoint (specifically adding it into a custom list Edit form). The schema for the project IDs is as follows:

Prefix + Leading Zeros + ProjectID.... so in SharePoint I would be looking for the format to be a concatenated value (PROJ,LeadingZeros,ListItemID). Essentially I have the PROJ prefix and then a five digit number with a variable amount of zeros based on the number of characters in the ID.

My script looks like this:
var fillZeroes = "00000"; // max number of zero fill ever asked for in global

function zeroFill(number, width) {
    // make sure it's a string
    var input = number + "";
    var prefix = "PROJ";
    if (input.charAt(0) === '-') {
        prefix = "-";
        input = input.slice(1);
        --width;
    }
    var fillAmt = Math.max(width - input.length, 0);
    return prefix + fillZeroes.slice(0, fillAmt) + input;
}
var testValue = "3";
var result;
for (var i = 0; i < testValue.length; i++) {
    result = zeroFill(testValue[i], 5);
    document.getElementById("projID").innerHTML = result;
}
http://jsfiddle.net/f6Vf9/

I am hoping to use SPservices to pull in the current items ID and incorporate it into the script I have above (i.e. - setting the variable "testValue" to the list Item's ID) and then posting this string to an empty single-line text field.

Any ideas on how I may be able to accomplish this? I am experiencing issues referencing the item's ID. Any help would be greatly appreciated. Thanks!!

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>