- 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-19-2024 01:04 AM
You could create a Read ACL for "incident.variables" so that only people who fulfill this ACL are allowed to read the variables.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 01:19 AM
Hi @Arjun Reddy Yer I think the issue is with your if condition, Can you keep alert inside your if and check whether the if condition is executing?
Harish
- 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-21-2024 07:25 PM - edited 01-21-2024 07:49 PM
Hi @Tai Vu ,
Created new Incident Variable Editor and created new UI Macro based on below script but it's not working.
The thing is the Variables on the incident for is to be visible only for the users who has specific role.
UI Formatter: Incident Variable Editor for AU
UI Macro: com_glideapp_questionset_default_question_editor_for_australia
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:requires name="scripts/js_includes_catalog.js" includes="true"/>
<g:requires name="styles/${new CatalogCssSelector().getVariableCss()}" includes="true"/>
<g:if_polaris>
<g:then>
<g:requires name="styles/${new CatalogCssSelector().getPolarisVariableCss()}" includes="true"/>
</g:then>
</g:if_polaris>
<g2:evaluate var="jvar_catalog_item">
function eval_cat_item() {
var cat_item = "";
var catItemProducedGr = new GlideRecord("sc_item_produced_record");
catItemProducedGr.addQuery("record_key", current.getUniqueValue());
catItemProducedGr.query();
if (catItemProducedGr.next())
cat_item = catItemProducedGr.getValue("producer");
return cat_item;
}
eval_cat_item();
</g2:evaluate>
<!-- load only the one_to_one variable sets -->
<g2:evaluate var="jvar_cat_sets" jelly="true">
var jvar_cat_sets = "";
var gr = new GlideRecord("io_set_item");
gr.addQuery("sc_cat_item", jelly.jvar_catalog_item);
gr.addQuery("variable_set.type", "one_to_one");
gr.query();
while (gr.next()) {
if (jvar_cat_sets.length > 0)
jvar_cat_sets += ",";
jvar_cat_sets += gr.variable_set;
}
jvar_cat_sets;
</g2:evaluate>
<g2:evaluate var="is_visible" jelly="true">
is_visible = gs.hasRole('Australia User');// Users having this role
</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>
</j:jelly>
it's still visible to all the users who is not having the role. @Vasantharajan N