- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 12:39 AM
How to show Incident Variable Editor to a specific users.
As the Variable Section on the incident form should be visible to specific users only.
As tried with OnLoad Client Script but it's not working.
Can anyone help me @Vasantharajan N
Like below variable section should be visible only to specific Users
Client Script Used:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 02:04 AM
From your screenshot, the Variables formatter is not yet under any Form Section.
You can create a new section for the Incident Variable Formatter, which is similar to below sections.
Then use the API below to show and hide section accordingly.
setSectionDisplay(String sectionName, Boolean display)
In the other hand, you can consider to clone the Formatter for your own customization.
Name: Incident Variable Editor
URL: https://<instance_name>/sys_ui_formatter.do?sys_id=710bb6ba0a0a0b0100ba712aa4b9f048
The Formatter above calls to an UI Macro named: com_glideapp_questionset_default_question_editor
Clone to the new one and apply specific conditions to display it. Sample below
<g2:evaluate var="is_visible" jelly="true">
is_visible = gs.hasRole('admin');
</g2:evaluate>
<div data-sn-macro-sys-id="${jvar_macro_sys_id}">
<j2:if test="$[is_visible]">
<j2:if test="$[jvar_catalog_item != '']">
<j2:set var="jvar_producer_target_record" value="true"/>
<g2:client_script type="catalog_question_editor" catalogItem="$[jvar_catalog_item]"/>
<g:inline template="catalog_ui_policy.xml"/>
<g2:render_component componentName="com.glideapp.servicecatalog.DefaultQuestionEditor"/>
</j2:if>
<j2:if test="$[jvar_catalog_item == '']">
<!--Render old default editor if catalog item is not found -->
<g2:render_component componentName="com.glideapp.questionset.DefaultQuestionEditor"/>
</j2:if>
</j2:if>
</div>
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 05:31 PM
Hi @Tai Vu ,
The thing is I had created a Catalog Item which Sys ID: eb7d7eb34772b514d2e14af4116d43b1 and it will produce Incident Record.
So based on that, only the particular Catalog Item which produce Incident Record variables should be visible on the incident form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 09:48 PM
Hi @Arjun Reddy Yer ,
Once again I would prefer achieve your requirement with minimal development effort leveraging the below,
- Form section that includes the Variable Editor formatter.
- onLoad client script that can assess the condition required to show/hide the form section.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 01:08 AM
2 ways to handle this
1) Use DOM manipulation and hide it which is not recommended
OR
2) add that variable editor formatter in a section and then hide that section
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 01:59 AM
Tried with the solution provided by @Tai Vu it's working but it should work only for a particular Catalog item which is having Request Method as Incident but it's working for normal incident also