Need help in Number field

Pihu1
Tera Contributor

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

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi @Pihu 

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:

find_real_file.png

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

10 REPLIES 10

Pihu1
Tera Contributor

Thank you Shloke for all the replies.