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

David,


I am looking for a similar solution, however I need the RITM short description to depends on a variable choice.   I need this so we can run reports on how many Exceptions were created and for how many Permenant were created.   My idea is I could grab these by their short description, otherwise the RITMs all look the same.   My workflow only creates a task for Perm and not Except - so I can't pull TASKS for the report.



Can I write an OnChange script in the catalog item to change the RITM short descrip dependant on that variable choice?





Hi Cheri,



The first thing I could say is "You probably don't need a onChange script" because you don't need to update a field value when the user is on the form but "You probably need a Server side script (business rule or workflow)" because you need to automatically modify once for all the field.



Then, if I were you, my questions would be:


  1. You're speaking about RITM and then about TASKS, on which level are you? (the Item (RITM) or the technical catalog task (TASK) to perform to deliver the RITM?)
  2. Do I want something (a field) dedicated to this information because the added value is very important (and generic enough for the other teams) or do I want it in any free text field or don't i really need it?
  3. You're speaking about reporting and about "day-to-day" operational usage, what does people need in these 2 situations? (and I would add "the most important is what is the most valuable for the end users", because we have to be end-user friendly)
  4. I can't configure anything with ServiceNow, what should I write in my training documentation? (it's really useful to do that to think about the different test cases)
  5. Then, I'll see about the technical questions


For example, I usually put the name of the "on behalf of" on the short description of the RITM or some other catalog variables like the country, because in the day-to-day use, it's easier to find the info for the end users...


The requester is working in the Superheros secretary's office and will see in the list of RITM:


  • Blackberry for James Bond (United Kingdom)
  • Blackberry for Batman (West USA)
  • Blackberry for Spider-Man (East USA)


But if my end users don't know what "Permanent" or "Exception" means, I won't put this info on the short description but maybe in a specific field visible only by the IT people.



Feel free to tell us more about the requirements to let us know explain what are the best options to take



Regards,


Hi David,



Sorry if I don't make sense.   Here is the situation.   I've made a catalog item that the first variable will ask "is this a permanent change or an exception".   Depending on that answer the form shows the correct variables and the workflow will go in either direction.   The only thing I want to change is the RITM created once the ticket is submitted.   If Perm is chosen, then the short description on the RITM should read "Technology Standard: Permanent" and if Exception is chosen; "Technology Standard: Exception".   That way we can see all of the requested items for either, otherwise it's just "Technology Standard"... which doesn't help much.



Tasks are irrelevant in this situation. I only have one and I know how to edit that in the workflow to read as I want (and it doesn't matter in this case anyway).



I've tried adding a script to the beginning of my workflow to add the variable to the short description. Is the RITM created before the workflow is fired or after?   I should know that but I haven't been doing this long   I thought it created the RITM THEN fired the workflow, which is why I thought it had to be in the catalog item, as a script or UI policy.



As far as reporting. The person that requested this catalog item wants to then report on it quarterly, to see how many Exceptions were created and how many Permanent changes were created.   I haven't found an easy way to do that.   Exception workflow path only gets approvals, then fires off a notification... or I'd run the report on tasks.



I could be overthinking this.   Usually I miss something and then wonder why it took me so long to figure that out.



Thanks so much!


Cheri







Thanks for clarify


http://wiki.servicenow.com/index.php?title=Scriptable_Service_Catalog_Variables should help



For the order of the execution: http://wiki.servicenow.com/index.php?title=Execution_Order_of_Scripts_and_Engines could help as well.



So what you need to do is to open the workflow associated to your item (not the Request) and to add a "script activity" just after the "begin".


The workflow (according the second link about the order of scripts) will be executed "before" the real "create" into the database (or before the real "update" for the next steps), so we don't need to have "current.update();" for example, we just need to do:


current.short_description = ....;



Feel free to make some tests and come back if you need more help




Attention points:


1) Make sure you're modifying the workflow triggered by the catalog item (or you'll do like me, you'll spend hours to understand why your modifications don't do nothing)


2) Make a first try like "current.short_description = 'My test to replace a short description using a workflow'; (just check if it's working well)


3) Then modify the script fulfill your requirement



Regards,


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