Setting default value for specific views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 01:33 PM
Hi Everyone, is there a way to set different default values for specific views?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 02:04 PM
Hm interesting. I'm in a scoped application so I will have to use a Script Includes right? Do you know how to query a table's view? Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 02:19 PM
You can use below code to get the view name in an onLoad Client script. Then using g_form.setValue('you field name','your value');, you can set the value of the field
var view = getParameterValue('sysparm_view');
function getParameterValue(view_name) {
var url = document.URL.parseQuery();
if (url[view_name]) {
return decodeURI(url[view_name]);
}
else {
return;
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 02:55 PM
hey @sanjivmeher, thanks for your suggestion, but since I'm doing this in a scoped application, don't I have to use a script includes? I've written the following script includes, but am having trouble calling it from an onLoad client script:
The Client Callable checkbox is checked to true.
var Employee_Experience_HR_Request = Class.create();
Employee_Experience_HR_Request.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
setValuesHrRequest: function () {
var me = gs.getUserID();
var gr = new GlideRecordSecure("x_dnf_hr_cases");
gr.setValue('hr_profile', me);
gr.setValue('state', 10);
gr.setValue('short_description', 'HR Service | HR Request');
var hr = gr.hr_profile.getRefRecord();
gr.setValue('assigned_to', 'hr.x_dnf_hr_contact');
},
type: 'Employee_Experience_HR_Request'
});
In my client script, I've chosen onLoad and unchecked Global and put in my specific View. However, what do code in order to call the above script includes? Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 03:26 PM
Even if it is a scoped App, the onLoad script I provided should work.
Whatever you are doing in script include can be done in client script.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2018 03:05 PM
var gr = new GlideRecord('sys_ui_form');
gr.addQuery('name=incident');
gr.query();
while(gr.next()) {
}
the column view holds the view. it is a reference field to sys_ui_view table