Maybe some of you have experienced this problem and maybe not. Maybe you just knew the answer but I couldn’t find it on here anywhere so when I figured it out, I figured I’d share.

In the current environment I’m working in, when a new account is entered into IDM, be it through IDM directly or via the HR system, the first 6 characters of the last name and a couple characters from the first name or nickname are then used to complete the MSKEYVALUE, which is in turn becomes the user’s Windows and SAP login IDs. We call this the 6+2 unique ID. The problem that was occurring was that if the person had spaces in their last name, that space counted as a character. It would get squeezed out when the actual MSKEYVALUE was created but it would then leave the ID in a 5+2 state.

For example, a name of “Jodi Van Camp”, “Van Camp” being the MX_LASTNAME, would turn out an MSKEYVALUE of “VanCaJo” when it should be “VanCamJo”.

The bottom line was, we needed to eliminate those spaces in the last name for the purpose of creating the MSKEYVALUE.

I thought it would be a simple replace using a script. Maybe something like this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(/\s+/g, "");
  return result;
}

Or maybe this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(/\s/g, "");
  return result;
}

Or this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(/ /g, "");
  return result;
}

Or lastly, this:


function z_eliminateWhitespace(Par){
  var result = Par.replace(" ", "");
  return result;
}

None of this seemed to work. I’ve had it happen way too many times where a SQL query or JavaScript won’t work exactly the way it should in IDM as it does in other environments so this wasn’t a total surprise but now what? Finally, I happen on the idea of splitting the string on the spaces and rejoining it without the spaces. This was the script I eventually came up with and it seems to work:


function z_eliminateWhitespace(Par){
  var result = Par.split(" ").join("");
  return result;
}

The final script had an IF line before the split / join checking Par to make sure it wasn’t empty or a NULL value but you get the general idea. Hope this perhaps helps someone out there someday.

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

    1. Brandon Bollin Post author

      The process is already in place in this environment to make sure the MSKEYVALUE is unique so that issue is already covered. Once an MSKEYVALUE is created, whether there’s spaces or not, it’s evaluated for uniqueness and if it’s not unique, there’s a tiebreaker routine. I just needed the process to not count spaces towards the first 6 characters in the MSKEYVALUE.

      Also, that’s just my specific issue. I’m sure there’s other issues out there where eliminating the whitespaces in a string will come in handy so this script can probably help out with a number of various issues.

      (0) 

Leave a Reply