custom short description

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?

10 REPLIES 10

LaurentChicoine
Tera Guru

Hi,



The problem with a catalog client script is that you won't get your RITM number until the request is actually submitted. Your left with Business rule or Workflow (run script). IIn this case, I would prefer a business rule as a workflow run script would create the record with the original short des and then update while the business rule will directly set the short description to your desired result.



To make your life easier for the maping with abreviation, you could set the value of the variable as the abreviation.



Here is an example of business rule:



Table: Requested Item(sc_req_item)


When: Before


Insert: true


Filter condition:


Item is [Select your catalog item]


Script


var shortDesc = current.number + current.variables.application + current.variables.request + ' ' + current.variables.short_description;


current.short_description = shortDesc;



This script assume that your application, request and short_description fields are mandatory, otherwise you could get some undefined value in there.



If you don't put the abreviation in the value you could use a map.



var abvrMap = {


        'Prod': 'PD',


        'Test': 'Test',


        'Dev': 'DV',


        ...


};



var shortDesc = current.number + abvrMap[current.variables.application] + abvrMap[current.variables.request] + ' ' + current.variables.short_description;


current.short_description = shortDesc;


I did the following:



Table: Requested Item(sc_req_item)


When: Before


Insert: true


Filter condition:


Item is [Select your catalog item]


  1. var abvrMap_app = {  
  2.         'Prod': 'PD',  
  3.         'Test': 'Test',  
  4.         'Dev': 'DV',  
  5.        
  6. };  
  7. var abvrMap_request = {  
  8.         'Change': 'CH',  
  9.         'Job Edit': 'JE',  
  10.         'General Support': 'GS',  
  11.        
  12. };  
  13. var shortDesc = current.number + abvrMap_app[current.variables.application] + abvrMap_request[current.variables.request] + ' ' + current.variables.short_description;  
  14. current.short_description = shortDesc;

For some reason I am getting the output as     RITM0030221undefinedundefined undefined



Any ideas?


Hi, please make sure you have the right variables name (name field), in the code I've submitted I assumed the name of the variables. but clearly at least for short_description it does not seem to be the right variable name as it is undefined.



Also for the map, make sure that the attribute name (ie: Prod) is the same as your question choice value (value field, case sensitive).


Hi,



I see the following for short description:


find_real_file.pngfind_real_file.png


The value is the same for fields under request. except the fields under application as that is a reference field and the set up was not done as choices but added in a different table.