Showing changes to variables in SC Items in the Activity register
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2014 07:20 AM
Hi, I can see the audit history for variables within service catalog items, however I want to show any changes within 'activity'.
I've tried adding all available fields within 'personalize activities' but this does not capture any changes to the variables.
Has anyone else managed to do this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2014 08:00 AM
i do not think activity will show this information ... but you might build a ui page and use the history set table information for this ....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2014 02:21 PM
I didn't want to audit the variables and needed the same thing... Sooooo... this will update the ITEM activity log with the changes made to any variable for that item.
I have only built this out in dev and haven't pushed to prod yet but tell me if you see any issues...
create a before BR on the Options table <sc_item_options>
this should ONLY run on an update with a condition of Value changes
check the advanced check box and put in the following script...
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.comments = 'Variable updated ' + current.item_option_new.getDisplayValue() + ' value changed from ' + previous.value + ' to ' + current.value + ' By ' + gs.getUserName();
itm.update();
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2014 10:31 AM
i had a minor issue in my original script that i cleaned up as i finished it up...it printed the value of select boxs etc which isn't easy to see for the customers
this new and improved version 2 script will go look up the text for the variable for you and put that in the activity field of the item.
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.comments = '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 = '';
qc = new GlideRecord('question_choice');
qc.addQuery('question',q_sid);
qc.addQuery('value',q_value);
qc.query();
if (qc.next()){
answer = qc.text.toString();
return answer;
}
else{return q_value;}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2014 01:50 PM
obtw.. expect version 3 sometime in the next week or two.. i want to have it return something meaningfull for every type of variable, including list collectors ref fields etc.