Name
sn_vsc.VscGetHardeningComparisonDatesForUser
Description
To get the dates of a comparison if exists for the user in sn_vsc_user_comparisons table. If it exists, it should give us two dates back ( ideally should be null, null ) or should just give us the comparison dates with isDefault as true from sn_vsc_user_comparisons table.
Script
var VscGetHardeningComparisonDatesForUser = Class.create();
VscGetHardeningComparisonDatesForUser.prototype = {
initialize: function() {},
getDatesForUser: function(user) {
var gr_comparisons = new GlideRecord("sn_vsc_user_comparisons");
var eQ = "usr_listLIKE" + user;
gr_comparisons.addEncodedQuery(eQ);
gr_comparisons.query();
/* If a comparison exist for the user, return the dates */
if (gr_comparisons.next()) {
var dates = gr_comparisons.usr_name.toString();
if (dates.contains('null')) {
return [];
}
return dates.split(',');
} else {
/* If the comparison doesn't exist for the user, return the default comparison */
gr_comparisons = new GlideRecord("sn_vsc_user_comparisons");
gr_comparisons.addQuery("usr_default", true);
gr_comparisons.query();
if (gr_comparisons.next()) {
return gr_comparisons.usr_name.split(',');
}
}
/* Return an empty array otherwise*/
return [];
},
type: 'VscGetHardeningComparisonDatesForUser'
};
Sys ID
272dc2d2c9319110f8772e958ddfc0c1