How to autofill a text (description) field in a template.

Jacob I
Tera Expert

Hello,

I'm creating some standard change templates and we want the text field "Description" to autofill the current Month when the standard change template is chosen.

For example:

Description: Patching for the month of {javascript:get.CurrentMonth}

The code above is obviously wrong as it's an example, but is there a script that can be put in there to get to pull the current month and read "September"?

Or is this something that can only be done through a business rule. If so, how would you go about coding the rule?

Thanks,

 

find_real_file.png

1 ACCEPTED SOLUTION

You have to change the variable name. Replace this line

current.u_hold_size = 'Patching for the month of '+str;

with

current.description = 'Patching for the month of '+str;

 

Please mark this post as helpful or the correct answer to your question if applicable.


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

3 REPLIES 3

Prateek kumar
Mega Sage

Use a Before BR, insert &  update - Checked

when to run : Condition based on your requirement.

Advanced:

(function executeRule(current, previous /*null when async*/) {

var gd = new GlideDate();
var str= gd.getByFormat("MMMM");
current.u_hold_size = 'Patching for the month of '+str;
})(current, previous);


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Jacob I
Tera Expert

Thanks for the reply but it doesn't appear to be working.

find_real_file.png

find_real_file.png

You have to change the variable name. Replace this line

current.u_hold_size = 'Patching for the month of '+str;

with

current.description = 'Patching for the month of '+str;

 

Please mark this post as helpful or the correct answer to your question if applicable.


Please mark my response as correct and helpful if it helped solved your question.
-Thanks