- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 01:09 AM
Hello,
I have overriden the Edit... button for the incident table as I have set a filter condition. The code is as below:
var uri = action.getGlideURI();
var path = uri.getFileFromPath();
uri.set('sysparm_m2m_ref', current.getTableName());
uri.set('sysparm_collection_related_file', current.getTableName());
uri.set('sysparm_form_type', 'o2m');
uri.set('sysparm_stack', 'no');
uri.set('sysparm_query', 'active=true^parent_incidentISEMPTY^child_incidents=0^company=' + current.company);
action.setRedirectURL(uri.toString('sys_m2m_template.do'));
The problem I am facing is that the "current" is not functioning as expected. I don't have access to any field value of the current record. Only current.sys_id is delivering random value. If I try to use the UI Action as client it won't work. Also current.variables.<field value> is not working. I even tried using onDisplay BR with g_scratchpad which didn't work.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 02:32 AM
Hello
Please check with below script you can get the current record sys_id and then use the sys_id to get the required details if needed:
var incidentGuid = action.getGlideURI().getMap().get('sysparm_collectionID');
var uri = action.getGlideURI();
var incidentGuid = action.getGlideURI().getMap().get('sysparm_collectionID');
var gr = new GlideRecord("incident");
if (gr.get(incidentGuid)) {
// get the required field details
}
var path = uri.getFileFromPath();
uri.set('sysparm_m2m_ref', current.getTableName());
uri.set('sysparm_collection_related_file', current.getTableName());
uri.set('sysparm_form_type', 'o2m');
uri.set('sysparm_stack', 'no');
uri.set('sysparm_query', 'active=true^parent_incidentISEMPTY^child_incidents=0^company=' + current.company);
action.setRedirectURL(uri.toString('sys_m2m_template.do'));
Please mark my respsone as helpful/correct, if it answer your question.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 01:22 AM
If UI Action is Client Side, you need to use below function to write Servicenow Side code.
gsftSubmit(null, g_form.getFormElement(), "ui action id") triggers the UI Action which is specified in the 3rd parameter, which is the action name/element id.
Use below link for sample:
https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
Please mark this as correct answer if it resolved, or mark this helpful if this help you to reach towards solution.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 02:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2023 06:24 PM
I have a doubt. I am setting this filter condition through code only. Once the filter is set, I want to make it Read-only for end users. No one should be able to change it manually ?
How to achieve this one?
Thank you,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2025 10:21 PM
Hi Asmita, Did you found the solution to this. Actually I am also facing same problem and need some assistance.