looking for some guidance on how to do this. (Transform map Scripting)

kusumgautam
Tera Contributor

your importing list of record and you want that whenever I am importing a data and I want to make sure that whatever data is getting inserted into database each and every letter of the that first alphabet should be capital so how will you do that.

 

Thank you!

2 ACCEPTED SOLUTIONS

Community Alums
Not applicable

Hi ,

To ensure that the first letter of each word is capitalized while importing data into ServiceNow, you can use a Field Transform Script in the Transform Map of your Import Set.

Solution: Field Transform Script in Transform Map

  1. Go to System Import SetsTransform Maps.
  2. Open the relevant Transform Map.
  3. Find the target field where you want to apply this transformation (e.g., name, description).
  4. In the Field Transform Script, add the following script:

 

(function transformEntry(source, target, map, log) {
    function capitalizeWords(str) {
        return str.replace(/\b\w/g, function(char) {
            return char.toUpperCase();
        });
    }

    target.name = capitalizeWords(source.name); // Modify 'name' field
})();

 

 

Explanation

  • The capitalizeWords(str) function ensures that every word in the string starts with an uppercase letter.
  • The Transform Script applies this function to the target field (name in this case) before inserting the data into the database.

View solution in original post

Ravi Gaurav
Giga Sage
Giga Sage

Hi @kusumgautam 

Goal:

When importing data into ServiceNow, we want to automatically capitalize the first letter of each word in a specific field (e.g., Name, Description).

How to Do It?

We’ll use a Field Transform Script in the Transform Map of the Import Set.

Steps to Implement:

  1. Go to System Import SetsTransform Maps
  2. Open the relevant Transform Map
  3. Find the Target Field (e.g., name)
  4. Add the following script under the Field Transform Script section


    var text = source.name; // Get the source value
    var words = text.split(" "); // Split into words
    for (var i = 0; i < words.length; i++) {
    words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1); // Capitalize first letter
    }
    target.name = words.join(" "); // Join words back into a single string


--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

2 REPLIES 2

Community Alums
Not applicable

Hi ,

To ensure that the first letter of each word is capitalized while importing data into ServiceNow, you can use a Field Transform Script in the Transform Map of your Import Set.

Solution: Field Transform Script in Transform Map

  1. Go to System Import SetsTransform Maps.
  2. Open the relevant Transform Map.
  3. Find the target field where you want to apply this transformation (e.g., name, description).
  4. In the Field Transform Script, add the following script:

 

(function transformEntry(source, target, map, log) {
    function capitalizeWords(str) {
        return str.replace(/\b\w/g, function(char) {
            return char.toUpperCase();
        });
    }

    target.name = capitalizeWords(source.name); // Modify 'name' field
})();

 

 

Explanation

  • The capitalizeWords(str) function ensures that every word in the string starts with an uppercase letter.
  • The Transform Script applies this function to the target field (name in this case) before inserting the data into the database.

Ravi Gaurav
Giga Sage
Giga Sage

Hi @kusumgautam 

Goal:

When importing data into ServiceNow, we want to automatically capitalize the first letter of each word in a specific field (e.g., Name, Description).

How to Do It?

We’ll use a Field Transform Script in the Transform Map of the Import Set.

Steps to Implement:

  1. Go to System Import SetsTransform Maps
  2. Open the relevant Transform Map
  3. Find the Target Field (e.g., name)
  4. Add the following script under the Field Transform Script section


    var text = source.name; // Get the source value
    var words = text.split(" "); // Split into words
    for (var i = 0; i < words.length; i++) {
    words[i] = words[i].charAt(0).toUpperCase() + words[i].slice(1); // Capitalize first letter
    }
    target.name = words.join(" "); // Join words back into a single string


--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/