- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2024 02:12 AM
Hi Community ,
I am facing an issue whenever using Transform map to make entries to CMDB, there is a column of 12 digit numeric ID as AWS ID but in the excel sheet my teammate get to import in table . It contains less than 12 digit because the number in starting are 000. For example In sheet I get a AWS ID as 123456789 but when I have to tranform it to CMDB table it should be displayed in AWS ID column as 000123456789 i.e 12 digits fixed always, if less than 12 while transforming I have to make it 12 digits by putting zeroes in front of the number. In some cases I tried to insert 000 (zeroes) in sheet itself before transforming but while transforming the transform map is removing the zeroes in front of the number .
Please help if someone have the knowledge on this .
Rohit Pargain
+918650834395
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 12:27 AM
You can use a transform script to add chars to the value before using it.
Something like this
answer = (function transformEntry(source) {
var id = source.u_field_name_of_aws_id;
var failsafe = 0;
//As long as the id is less than 12 chars long then we add a 0 before
while(id.length < 12 && failsafe < 10){
id = '0' + id;
failsafe++; //prevents infinite look in case something goes wrong - a max of 10 loops
}
return id; // return the value to be put into the target field
})(source);
Then set the target field to the field you want the ID set.
This isnt tested though but hopefully it helps a bit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 12:15 AM
Any help or idea will be beneficial for my learning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-11-2024 12:27 AM
You can use a transform script to add chars to the value before using it.
Something like this
answer = (function transformEntry(source) {
var id = source.u_field_name_of_aws_id;
var failsafe = 0;
//As long as the id is less than 12 chars long then we add a 0 before
while(id.length < 12 && failsafe < 10){
id = '0' + id;
failsafe++; //prevents infinite look in case something goes wrong - a max of 10 loops
}
return id; // return the value to be put into the target field
})(source);
Then set the target field to the field you want the ID set.
This isnt tested though but hopefully it helps a bit