How to set short description on Request Item that includes a variable

sandyml
Kilo Expert

Hi Everyone,

We have a request / workflow set up. We a variable on the Request Item & Catalog Tasks call user.

We want to dynamically update the short description of the Request Item based on the value in the user variable.

I've tried adding the following code to first catalog task (this is the point in the workflow where the user variable gets filled out): current.short_description = "MiWorkspace Onboarding for " + current.variables.user;

No luck.. however if I hardcode "Test" instead of putting current.variables.user, the short description is updated so I am not sure why it is behaving this way.

Also added a business rule in case that is necessary:

"After', Insert/Update, (but we tried both before and after)

var item = new GlideRecord('sc_req_item');

item.get(current.request_item.sys_id);

item.assignment_group = current.assignment_group;

item.update();


Does anyone have any ideas of what we can do??

thanks!

10 REPLIES 10

Hi, Thanks for the feedback. I've added the code to the activity that creates the task in the workflow. However, I am looking to change the Request Item Short Description,   and incorporate the "user" variable into the Request Item short description.


If you're in the workflow for a catalog item, here's how you'd go about changing short descriptions.



For Request Item itself


current.short_description = "bla bla bla bla " + current.variables.user.getDisplayValue();


  • That getDisplayValue part is essential if user is a reference.   Otherwise your user will look something like your keyboard threw up.
  • You may want to do this in a Run Script activity early in the workflow (first activity?) so you don't have to wait until partway through the flow until it actually renames the ReqItem's short description.


For Specific Tasks in the Workflow


task.short_description = "blablablbal " + current.variables.user.getDisplayValue()


Hello! Thanks for this.. I tried that and it's not doing the trick. It is hard to explain, but I put this in a catalog task because of some other functionality we have. So, in this instance, the task is created, and there is no name in the 'user' variable. The task is created, then the user name is populated. So I think maybe a business rule is also needed. Because basically I am trying to update the request item short description once the task is updated or closed (which is when the name field is filled in)



Thanks for any help


ok you just explained why it isn't working.. the script to populate the task short description runs when the task is created and the user variable is blank...



when the user variable is populated is that task then closed or what happens??



i can see two options here... .



1> if they close a task when they populate the user variable you can put a run script right behind it that will update already created child tasks with the users name



2> and this would be more interesting... create a wait for path that checks to see if the user variable is blank.. and when it is no longer blank will go fill it in.


That is interesting. I'd be interested in option #2, but haven't ever used a wait for condition.


I put one in before the task - selected the variable.   Set the condition to variable is empty.


This is in the condition script.


// Set the variable 'answer' to true or false to indicate if the condition has been met or not.


answer = true;


Nothing seems to be happening still. Am I on the right track w/ this?



Thank you