- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 01:09 AM
Hi Community,
I have a requirement where I need to change the prefix of Number field onchange of a field. For example if State changes to 'XYZ' the prefix should be 'ABC' and if the state changes to 'TEST' the prefix should be 'abc'.
How we can achieve this?
thanks in advance.
Pihu
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 06:08 AM
Hi
Agree to what Mark has said and would suggest altering number is not a good practice to set it to something apart from what has been set in Number maintainenence table as it can cause issue with multiple starting number for different records present on the same table.
Also would make it difficult for user to search and they might not be aware that there are set of records which starts with custom string like abc
But still if you want, you can write a on Change client Script on State field and use the script below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if(newValue == 2){
var getCurrentNumber = g_form.getValue('number');
var extractDigit = getCurrentNumber.substr(3,getCurrentNumber.length); // Replace 3 with the number from where your current number digit is starting. Like for example I have done this for Incident table where number currently starts with "INC0010126" so I am eliminating INC
var updatedNum = 'abc' + extractDigit;
g_form.setValue('number',updatedNum);
}
//Type appropriate comment here, and begin script below
}
Result:
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 07:19 AM
Thank you Shloke for all the replies.