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

that is the correct path.. but it is going to need to poke the workflow to tell it to check the wait for...



there are a couple of ways to do this... what i would do is create a script that when a variable is modified will update the item with the fact that the variable was changed from what and to what.. this will provide you an audit trail AND poke the item both in one swell foop


i have a BR on the Options table (sc_item_option) that does this



this is an before update br with a condition of value changes


__________Script___________   <note this will not put in a real value for a few types of variables and returns a sid instead.. but works for most______________



    if (previous.value != current.value){


            var var_owner = new GlideRecord('sc_item_option_mtom');


            var_owner.addQuery('sc_item_option',current.sys_id);


            var_owner.query();


            if (var_owner.next()){


                    var itm = new GlideRecord('sc_req_item');


                    itm.addQuery('sys_id', var_owner.request_item);


                    itm.query();


                    if (itm.next()){


                          itm.work_notes = 'Variable updated: ' +   current.item_option_new.getDisplayValue() + ' , value changed from ' + getValues(previous.value,current.item_option_new) + ' to ' + getValues(current.value,current.item_option_new) + ' By ' + gs.getUserName();


//itm.description = 'test';


                          itm.update();


                  }          


            }


    }


function getValues(q_value,q_sid){


  var answer = '';


    var q_type = new GlideRecord('question');


    q_type.addQuery('sys_id', q_sid);


    q_type.query();


    while(q_type.next()){


    switch(q_type.type.toString()){



            case('5'):   // Select box


                                              var qc = new GlideRecord('question_choice');


                                              qc.addQuery('question',q_sid);


                                              qc.addQuery('value',q_value);


                                              qc.query();


                                              if (qc.next()){


                                                            answer = qc.text;


                                              }


              break;


              case('14'): //macro


                            answer = "Macro was changed";


                break;


                case ('15'):   //UI Page


                          answer = "UI Page was changed";


                break;


              case('18'):   //lookup select box   investigate this.


                                answer = q_value;


              break;


              case('21'): //list collectior investigate this


                                  answer = q_value;


              break;


              case ('22'): // lookup multiple choice   investigate this


                                answer = q_value;


              break;


              case('23'): //html


                                answer = "HTML was changed";


              break;


              case('3'): //Multiple choice


                                              qc = new GlideRecord('question_choice');


                                              qc.addQuery('question',q_sid);


                                              qc.addQuery('value',q_value);


                                              qc.query();


                                              if (qc.next()){


                                                            answer = qc.text;


                                              }


              break;


              case('8'): //reference  


                        var getReferenceDisplayValue = new GlideRecord(q_type.reference.toString());


                        if(getReferenceDisplayValue.get(q_value)){


                                answer = getReferenceDisplayValue.getDisplayValue();


                        }


              break;


                  default:


                          answer =   q_value;


            break;


  }


  if (answer == ''){answer = 'Null';}


  return answer;


}


}