How to show Incident Variable Editor on Incident form to a specific users

Arjun Reddy Yer
Tera Guru

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

ArjunReddyYer_0-1705653458635.png

Client Script Used:

 

ArjunReddyYer_1-1705653525271.png

 

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @Arjun Reddy Yer 

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.

Screenshot 2024-01-19 at 16.59.15.png

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

View solution in original post

13 REPLIES 13

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.

 

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Arjun Reddy Yer 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

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