How do I dynamically modify RITM & TASK short descriptions based on Catalog Item short desc. & cat item form variable?

GoBucks
Mega Sage

I'm trying to find a way to dynamically modify the short description for the related RITMs and TASKs records that get created when an REQ is created from submission of a Catalog Item form.

 

For example, we have a Catalog Item named "Event Request" that has a defined short description of "Event Request" in its short description field.   The REQ that gets created from submission of this cat item form has one related RITM with one related TASK, where each of the short description fields of the RITM & related TASK simply state the same short description of "Event Request".

 

So, currently when one looks at their assigned TASKS that originated from this catalog item they'll see in the list view short descriptions looking like this:

TASK0000001 - Event Request

TASK0000002 - Event Request

TASK0000003 - Event Request

Hard to differentiate at a glance.

 

This particular catalog item form contains a variable, event_name, where the user enters the name of the event.   It would be preferable if prior to insert of these RITMs & TASKs if their short descriptions could be modified to be the original short description (from the Catalog Item's short description) plus the value of the event_name variable the user submits on the form.

 

If the above mentioned modification could happen, a list view with unique short descriptions for each TASK could be possible:

TASK0000001 - Event Request: Annual Tech Conference

TASK0000002 - Event Request: monthly budget meeting

TASK0000003 - Event Request: holiday party

Much easier to differentiate at glance.

 

Essentially... short_description + ": " + event_name but how can this be achieved?

 

Business Rule/event, or client-side script via onSubmit()?   As I'm relatively new to the scripting aspects within Service Now I'm not exactly sure how this can be achieved.

 

Thanks in advance!

Jeff

1 ACCEPTED SOLUTION

david_legrand
Kilo Sage

Hi Jeff and Justin,



If you're creating the task using the workflow editor, I would rather use the "advanced script" on the task creation:


find_real_file.png



task is the sc_task I'm creating, current is the sc_req_item


This way you'll save not necessary database updates and your workflow will be easier to understand



But that don't tell you why using Business Rules, Client Scripts or the workflow directly as here


View solution in original post

11 REPLIES 11

justin_drysdale
Mega Guru

Do you have a workflow attached to the item?   If so you can use a run script event within the workflow:



current.short_description = current.short_description + ": " + current.variables.event_name;


current.update();



If you don't have a workflow I suggest making one for this fix.   You can use a BR or client script but a workflow is better for this.



Service Catalog Workflows - ServiceNow Wiki


Thanks Justin.   Yes there is a simple workflow attached to the item.


david_legrand
Kilo Sage

Hi Jeff,



The first question we have to ask you is "Do you use the 'Workflow', the 'Execution Plan' or 'Manual creation' for managing your tasks of the RITM?"


Because the answers might change a bit according the features you're using



In fact, to understand the different scripts, you have to start asking yourself the "functional questions" (not technical) "when the task are created?" and "by who?"



Regards,


David


ps:I think the best way for learning is to answer questions, that why I'll ask you some questions to let you find the right answers


Thanks David. This item uses a workflow.