- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 10:27 PM
i want custom field where i want INC -23 24 -0010008 as a number
INC - Initials of incident
23 24 - current financial year
0010008- remaining number digit from the original number field of that record
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 11:27 PM
Hello Shantanu,
You need to create a field on incident table for custom number field and write a business rule as per your condition either on insert or update
and write the below script
And it will give you the solution as below
Hope this will help you in solving
Please mark the answer as helpful and correct if it helped
Thanks,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 11:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 11:27 PM
Hello Shantanu,
You need to create a field on incident table for custom number field and write a business rule as per your condition either on insert or update
and write the below script
And it will give you the solution as below
Hope this will help you in solving
Please mark the answer as helpful and correct if it helped
Thanks,
Priyanka
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2023 02:30 AM
Thank You @Community Alums
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2023 11:35 PM
Hello @Shantanu Arora ,
Please create a business rule and mention the below code in the it
var firstyear;
var secondyear;
var f;
var g;
var gdt = new GlideDateTime(gs.nowDateTime());
if(gdt.getMonth()+1 <=3)
{
firstyear = gdt.getYear()-1;
secondyear = gdt.getYear();
f = firstyear.toString().slice(2);
g =secondyear.toString().slice(2);
}
else
{
firstyear = gdt.getYear();
secondyear = gdt.getYear()+1;
f = firstyear.toString().slice(2);
g =secondyear.toString().slice(2);
}
current.field_name='INC - '+f + ' ' + g + current.number.toString().slice(3); // as incident has 3 characters INC to be removed.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.