Auto-populate Short Description with Text

nichostetler
Giga Contributor

Right now, I have a script that auto-populates the short description in the Requester Information, with what it inputs in the Server Name variable as shown in the attached image. The problem is, it only pulls the short description and doesn't add the text I want it to.

servicenow.PNG

Here is my code:

current.short_description = "Server Decommission request - " + current.variables.ShortDesc.getDisplayValue();

Note:

the Sever Name variable is ShortDesc

the Short Description is short_description

1 ACCEPTED SOLUTION

You don't have Insert or Update checked on the business rule. This leads me to believe something else is setting it because this business rule never ran!


View solution in original post

9 REPLIES 9

Give a condition in filter condition of when to run section in the business rule like item is "Your item name". So it will run only for this catalog item.


Additionally, as a best practice, check if the variable actually has a value before using it.



if (current.variables.ShortDesc)


        current.short_description = "Server Decommission request - " + current.variables.ShortDesc.getDisplayValue();


Okay so I created a business rule (show in the following picture) and it still is just pulling the Server Name variable and not the text.



sn4.JPG



sn5.JPG


sn6.JPG


You don't have Insert or Update checked on the business rule. This leads me to believe something else is setting it because this business rule never ran!


Thank you so much for all your help! That worked!