
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 06:44 AM
I have a script include with an 'if' condition. I want to call this condition by using system property. I mean I want to create a system property for this condition and then call this 'if' condition via that system property. Would be grateful if someone gives me a detailed answer.
var ACLRestrictions = Class.create();
ACLRestrictions.prototype = {
initialize: function() {},
myFunction: function() {
if (gs.hasRole('admin') || gs.hasRole('itil_admin') || gs.hasRole('itil') || gs.hasRole('public') || gs.hasRole('snc_platform_rest_api_access')|| gs.hasRole('rest_service')|| gs.hasRole('kubernetes_discovery_api')|| gs.hasRole('approver_user')) {
//show full record
} else {
var uID = gs.getUserID();
var uGR = new GlideRecord("sys_user");
uGR.get(uID);
var q = current.addQuery('manager', uGR.manager);
}
},
type: 'ACLRestrictions'
};
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 06:56 AM
Hi,
Why not just create the property as a string and call it?
Property:
name: myIfCondition
type: string
value: gs.hasRole('admin') || gs.hasRole('itil_admin') || gs.hasRole('itil') || gs.hasRole('public') || gs.hasRole('snc_platform_rest_api_access')|| gs.hasRole('rest_service')|| gs.hasRole('kubernetes_discovery_api')|| gs.hasRole('approver_user')
and then in your script:
if(gs.getProperty('myIfCondition') {
//some action...
}
harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 06:56 AM
Hi,
Why not just create the property as a string and call it?
Property:
name: myIfCondition
type: string
value: gs.hasRole('admin') || gs.hasRole('itil_admin') || gs.hasRole('itil') || gs.hasRole('public') || gs.hasRole('snc_platform_rest_api_access')|| gs.hasRole('rest_service')|| gs.hasRole('kubernetes_discovery_api')|| gs.hasRole('approver_user')
and then in your script:
if(gs.getProperty('myIfCondition') {
//some action...
}
harel