Generate codes for Tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 08:04 AM
Hello All,
I want to generate codes with all possible combinations of AA999. i.e If a user's name is Kathy Joe,
The code should be generated as KJ980. I want to generate data to be filled in with Tables using background scripts. How can I achieve it.
PS: Code = First Name initial + Last Name initial + Combination of 3 numbers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 08:11 AM
Hi,
You can create a custom table to generate sequential number automatically and append with the initials.
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 08:08 AM
Hi @kpanchal
Check this OOTB code on user Name Field
https://INSTANCENMAE.service-now.com/now/nav/ui/classic/params/target/sys_dictionary.do%3Fsysparm_query%3Dname%253dsys_user%255eelement%253dname%26sysparm_query_encoded%3Dname%253dsys_user%255eelement%253dname%26sysparm_referring_url%3Dsys_user.do%253fsys_id%253d62826bf03710200044e0bfc8bcbe5df1%254099%2540sysparm_record_rows%253d814%254099%2540sysparm_record_target%253dsys_user%254099%2540sysparm_record_list%253dORDERBYname%254099%2540sysparm_record_row%253d2%26sysparm_view%3Dadvanced%26sysparm_view_forced%3Dtrue
Take a base and use in background script.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-27-2023 09:23 AM
Hi,
Yes, use background script or fix script to achieve it. Define the custom table as mentioned below.
I believe you are going to apply this for the entire sys_user table. Use active is true query it and define var x = 980 (Define it as per your wish)
Use charAt(0) for first_name & Last Name field.
Store it to the variable and amend with numberic i.e., x once provided the output you should increment it like x++ for next name and number definition.
var str = "HELLO WORLD";
str.charAt(0);// returns H
Suresh.