- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 07:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 10:57 PM
Hi,
UI Action based approach based on problem table which is related list on Incident table
1) Visit this OOB UI Action -> Edit on Global Table
URL: https://instanceName.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=7fff4c3d0a0a0b3400ad3f1a1d613f74
Update as this so that you create new button for your related list table
a) Action name - sysverb_edit_o2m_problem
b) Condition: (new GlideRecord(current.getTableName())).canWrite() && RP.isOneToMany() && !RP.getListControl().isOmitEditButton() && current.getTableName() == 'problem'
c) Script:
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', '');
uri.set('jvar_no_filter', 'true'); // added new
action.setRedirectURL(uri.toString('sys_m2m_template.do'));
d) Do Insert and Stay
2) Now Visit the Edit button which is OOB and update the condition as this so that the OOB button is not visible for your table
URL: https://instanceName.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=7fff4c3d0a0a0b3400ad3f1a1d613f74
Condition: (new GlideRecord(current.getTableName())).canWrite() && RP.isOneToMany() && !RP.getListControl().isOmitEditButton() && current.getTableName() != 'problem'
OOB UI Action After changes
New Edit button
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 10:49 PM
Hi Arkesh,
as you have a custom table I cannot reproduce your settings on my PDI, but I think I found at least one problem.
Wrong
uri.set('sysparm_m2m_ref', 'current.getTableName()');
Correct
uri.set('sysparm_m2m_ref', current.getTableName());
If the error remain please take an existing OOTB "Edit" UI Action for related lists and copy the code. And don't forget the line uri.set('jvar_no_filter', 'true'); for disabling the condition builder
Kind regards
Maik
If my answer replied your question please mark appropriate response as correct so that the question will appear as resolved for other users who may have a similar question in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 10:31 PM
This worked well for me
use DOM manipulation + UI Script
DOM is not recommended.
1) Create UI Script
a) Name - hideFilter
b) UI Type - Desktop
c) Global - True
d) Script: Below
Note: Ensure you give the proper table name in the indexOf() as per your table on which related list is used
I was on incident form and clicked on Edit button from Problem related list. You use yours
So I used sys_target=problem
addLoadEvent(hideButtonsAdd);
function hideButtonsAdd()
{
if(document.URL.indexOf('sys_target=problem')!=-1) // change the table name "problem" value as per the related list being used by you
{
gel("_add").disabled = true;
gel("_run").disabled = true;
}
}
Output: Add Filter and Run Filter is Disabled
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2021 02:48 AM
Hi @Ankur Bawiskar
I've just tried your solution and did some additional changes in the script, based on my requirements. I would only like to hide one condition (marked in red below):
My UI script:
Outcome (all conditions get hidden):
Is there a way to only hide one condition from users? Locking it from editing would also work in my situation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 10:57 PM
Hi,
UI Action based approach based on problem table which is related list on Incident table
1) Visit this OOB UI Action -> Edit on Global Table
URL: https://instanceName.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=7fff4c3d0a0a0b3400ad3f1a1d613f74
Update as this so that you create new button for your related list table
a) Action name - sysverb_edit_o2m_problem
b) Condition: (new GlideRecord(current.getTableName())).canWrite() && RP.isOneToMany() && !RP.getListControl().isOmitEditButton() && current.getTableName() == 'problem'
c) Script:
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', '');
uri.set('jvar_no_filter', 'true'); // added new
action.setRedirectURL(uri.toString('sys_m2m_template.do'));
d) Do Insert and Stay
2) Now Visit the Edit button which is OOB and update the condition as this so that the OOB button is not visible for your table
URL: https://instanceName.service-now.com/nav_to.do?uri=sys_ui_action.do?sys_id=7fff4c3d0a0a0b3400ad3f1a1d613f74
Condition: (new GlideRecord(current.getTableName())).canWrite() && RP.isOneToMany() && !RP.getListControl().isOmitEditButton() && current.getTableName() != 'problem'
OOB UI Action After changes
New Edit button
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2021 11:31 PM
Hi,
I have made, but problem here is we need to filter should work but not able to change based on roles.
Thank you,
Arkesh