The CreatorCon Call for Content is officially open! Get started here.

make short description change with variables

osvaldo2
Kilo Contributor

Hi All,

I have a question, I am trying to get the task short description change based on what is selected when the from is submitted.

On the form I have two variables: a reference variable named "Application" and a select box variable named "Request". I also have the short description variable on the form. Each of the variables have the following options when selected:

Application     Request

Prod                         Change

Test                           Job Edit

Dev                             General Support

I need to have the variables be the following when selected : Prod = PD, Test = Test, Dev = DV, Change = CH, Job Edit = JE, and General Support = GS so that in turn the

the short description on the task be changed to the following:

RITMXXXX+application+request+whatever was entered on the short description:

In other words if on the form I choose Prod and Change and have the short description "making change" then the actual wording on the short description box on the task would be: RITMXXXPDCH making change.

I thought about doing a client catalog script with the following but I am lost on how to get the rest to work as I want too. Any ideas on what is the best way to accomplish this?

if (!current.variables.var_ci.nil()) {

  task.cmdb_ci = current.variables.var_ci;

}

if (current.variables.Application == "Prod"){

}else if (current.variables.Application == "Test"){

}else if (current.variables.Application == "Dev"){

6 REPLIES 6

marcguy
ServiceNow Employee
ServiceNow Employee

current.variables.var_ci; won't work in the client as current.variables. is for server side code, I would try doing this with a Business Rule on insert of the task/request item conditioned so it only runs on the items it should.


What would be the proper syntax for the Client Catalog Script to set the Short Description based on a variable on the form it's submitting?


marcguy
ServiceNow Employee
ServiceNow Employee

well rather than using a catalog client script, you could use the before business rule on the request item table to set the short description from the variable.



current.short_description = current.variables.variablename



you would just need to make sure it's properly conditioned to only run when that particular item has been ordered


There's always this underlying tone of "Business Rules are bad".   Because they are hidden gotcha.   It just seems like a place you'd get cut, a "last resort".   "Oh, let me set up a silent change RIGHT before insert because nothing is working properly."



My intent was to keep everything "in one place", in the Catalog.  



If it can't be done, it can't be done.   I just like knowing more than one way to skin a cat.