how to get a variable on request item to populate on the catalog item short description

humblecommitted
Kilo Guru

Hello Community,

I am trying to get a variable called "ritm_short_description" on the catalog item to populate the "short_description" field on the request item.

Here is the catalog item:

find_real_file.png

Here is the variable on the catalog item:

find_real_file.png

Here is how I would like it to be displayed as after the catalog item has been submitted and is now a request item:

find_real_file.png

find_real_file.png

I have been trying workflows and business rules and i am not sure what i am doing wrong.

find_real_file.png

find_real_file.png

Please help!

Thanks in advanced.

1 ACCEPTED SOLUTION

Did you try this in the workflow in the run script activity. This run script activity should be your first activity in the workflow. Or you could also write a before business rule on the sc_req_item table



Run script activity:


current.short_description=current.cat_item.short_description+' '+current.variables.ritm_short_description;



Business rule:


When: before insert


Conditions: Item is <select the catalog item>


Script:


current.short_description=current.cat_item.short_description+' '+current.variables.ritm_short_description;


View solution in original post

13 REPLIES 13

Looks like Harry and Greg were correct on this and it worked when I used it as a business rule.  



Still trying to figure out the workflow method. Any leads?


find_real_file.png


siva_dirisala
ServiceNow Employee
ServiceNow Employee

Hello humblecommittedstudent, you have multiple options depending on what you actually want to do.



1) If you are just looking for the list view to show the cat item description, you can actually configure the list view and add the dot-walked field. You can just add cat_item.short_description. This way, even if the cat item short description is changed, it will always be showing the right description in the list against your req items.


2) If you want to denormalize the short description, then you simply have to have a BR on sc_req_item which just does



current.short_description = current.cat_item.short_description



There is no need to involve variables at all here.


Nevermind, I understood your requirement. You want to concatenate the short_description from the Catalog Item and the value from a variable. So, you would do something like



if(current.short_description.indexOf(current.variables.special_variable) < 0) {


        current.short_description = current.short_description+" "+current.variables.special_variable;


}



You want to make sure you are doing the concatenation only once and hence the check.


Hello Siva,



I tried the code but I do not think I am able to get it working, am i doing something different?



Here is the code I have:


if(current.short_description.indexOf(current.variables.ritm_short_description) < 0) {


      current.short_description = current.short_description+" "+current.variables.ritm_short_description;


}



ritm_short_description is from the rc_req_item table



and short_description is from the catalog_item table.



Thank you all for your assistance.


Did you try this in the workflow in the run script activity. This run script activity should be your first activity in the workflow. Or you could also write a before business rule on the sc_req_item table



Run script activity:


current.short_description=current.cat_item.short_description+' '+current.variables.ritm_short_description;



Business rule:


When: before insert


Conditions: Item is <select the catalog item>


Script:


current.short_description=current.cat_item.short_description+' '+current.variables.ritm_short_description;