Convert variable data to lowercase
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2015 09:24 AM
We have a string variable that we'd like to either force the data entered to be lowercase or either convert the information to lowercase once the record producer is submitted. This variable is populating the cmdb_ci on a change request.
Here's part of the script from the record producer. We're opening a change request and needing the server CI's that's being keyed in on the variable to be lowercase. The group didn't want the variable to be a reference field (long story).
current.cmdb_ci.setDisplayValue(producer.tempservername);
Tried the two below but didn't work:
//current.cmdb_ci.setDisplayValue(producer.finalsrvname.toString().toLowerCase().replace(/\s/g, '').trim());
//current.cmdb_ci.setDisplayValue(producer.finalsrvname.toLowerCase());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2015 09:30 AM
If you are setting a string field you don't need to use setDisplayValue. You can use setValue() or just set it directly. Try:
current.cmdb_ci = producer.tempservername;
or
current.cmdb_ci = producer.finalsrvname.toLowerCase();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2015 11:16 AM
Hey Justin,
Sorry, I may not have explained that correctly. The variable is a single line text but the cmdb_ci field on the change request is a reference field. So, if they type the server name in uppercase on the record producer, I need to convert that to lowercase on the change request. The problem is with sometimes have the same server name listed twice in our system, one for windows server and one for vm instance. The vm instance is uppercase and so our change request are being opened with the vm instance server name instead of the windows server name (lowercase). I've tried the script and it still doesn't seem to work. Strange...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2015 11:27 AM
Hello Andrea,
Try it like this:
current.setDisplayValue('cmdb_ci', producer.finalsrvname.toLowerCase());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2015 11:57 AM
Geez, doesn't like that either. I did go ahead and see if it would change the server name to lowercase on the short description and
it works. Seems to be having trouble setting the server name on the change request.
if (producer.tempservername == ''){
current.short_description = "Server Go Live " + "-" + producer.finalsrvname.getDisplayValue().toLowerCase(); CHANGED IT HERE.
current.description = "Server Go Live " + "-" + producer.finalsrvname.getDisplayValue();
//current.cmdb_ci.setDisplayValue(producer.finalsrvname.toString().toLowerCase().replace(/\s/g, '').trim());
//current.cmdb_ci.setDisplayValue(producer.finalsrvname.toLowerCase());
//current.cmdb_ci.setValue(finalsrvname.toLowerCase());
//current.cmdb_ci = producer.finalsrvname.toLowerCase();
//var FinalName = producer.finalsrvname + "";
//current.cmdb_ci.setDisplayValue(FinalName.toLowerCase());
current.setDisplayValue('cmdb_ci', producer.finalsrvname.toLowerCase());
Here's what it looks like.
We'd like to populate the server name in lowercase, but it forces the uppercase server name they enter on the
record producer. Like what's in the description.