Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function executeRule(current, previous /*null when async*/) {
- var maProperty = 'cmdb.managed_attributes.' + current.sys_class_name.toString(); //get managed attributes property
- var fieldsArray = gs.getProperty(maProperty).split(','); //convert comma separated attributes string into an array
- var oldValues = ''; //used for populating previous (old) values
- var newValues = ''; //used for populating current (new) values
- var configExc = false;
- for(var i = 0; i < fieldsArray.length; i++) {
- if(previous[fieldsArray[i]] != current[fieldsArray[i]]){ //check if the value of current element is changed
- configExc = true; //one of the managed attributes is changed, so we need a config exception record
- oldValues += current[fieldsArray[i]].getLabel() + ': '+ previous[fieldsArray[i]].getDisplayValue() + '\n';
- newValues += current[fieldsArray[i]].getLabel() + ': '+ current[fieldsArray[i]].getDisplayValue() + '\n';
- }
- }
- if(configExc){ //only create a config exception record if one of the managed attributes is changed
- var type = previous.install_status == "" ? "new_ci" : "ci";
- var gr = new GlideRecord('u_config_exceptions');
- gr.initialize();
- gr.u_ci_name = current.sys_id;
- gr.u_type = type;
- gr.u_old_values = oldValues;
- gr.u_new_values = newValues;
- gr.insert();
- }
- })(current, previous);
Add Comment
Please, Sign In to add comment