- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 03:20 AM
In location table, there is a reference field for company, which I have return following advance Reference qualifier.
javascript:new location_AdvRefQ().fncGetAllowedCompanies();
In the code, else part doesn't seem to be working where I don't want to return any companies if the user is not admin.
So what can the correct code be?
var location_AdvRefQ = Class.create();
location_AdvRefQ.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fncGetAllowedCompanies: function(){
strQuery = 'customer=true';
if (gs.getUser().hasRole('admin')) {
return strQuery;
}
else
{
strQuery=' ';
return strQuery;
}
},
type: 'location_AdvRefQ'
});
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 03:25 AM
try this:
var location_AdvRefQ = Class.create();
location_AdvRefQ.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fncGetAllowedCompanies: function(){
strQuery = '';
if (gs.getUser().hasRole('admin')) {
strQuery = 'customer=true';
}
return strQuery;
},
type: 'location_AdvRefQ'
});
EDIT: Actually not sure what returning a blank value will do, if it will return no records or all records. You could try below instead if above doesn't work:
var location_AdvRefQ = Class.create();
location_AdvRefQ.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fncGetAllowedCompanies: function(){
strQuery = 'sys_id=1234';
if (gs.getUser().hasRole('admin')) {
strQuery = 'customer=true';
}
return strQuery;
},
type: 'location_AdvRefQ'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 03:25 AM
try this:
var location_AdvRefQ = Class.create();
location_AdvRefQ.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fncGetAllowedCompanies: function(){
strQuery = '';
if (gs.getUser().hasRole('admin')) {
strQuery = 'customer=true';
}
return strQuery;
},
type: 'location_AdvRefQ'
});
EDIT: Actually not sure what returning a blank value will do, if it will return no records or all records. You could try below instead if above doesn't work:
var location_AdvRefQ = Class.create();
location_AdvRefQ.prototype = Object.extendsObject(AbstractAjaxProcessor, {
fncGetAllowedCompanies: function(){
strQuery = 'sys_id=1234';
if (gs.getUser().hasRole('admin')) {
strQuery = 'customer=true';
}
return strQuery;
},
type: 'location_AdvRefQ'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 03:30 AM
Hi,
In this case you can return a filter combination which is not true for any record.
for example if the table is incident then return 'priorityIN9', which is not true for any record.
If you are returning empty or null it will give all the records present for the table.
Thanks
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 03:32 AM
You can also use:-
strQuery= "NULL";
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 03:56 AM
Hi,
You can return the following in your else statement to make sure no results are found:
...
} else {
strQuery = 'sys_id=none';
}