How to make variables non editable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 01:45 AM
Hello,
I have created a catalog item using scripted rest api and add variables to catalog items using scripted rest api.I have provided the default values to these variables, so that anyone who wants to order that catalog item can go through the info stored in those variables.These variables look like this in service catalog when I open my catalog item to order it.
But what is happening now that values of these variables are editable, as anyone can edit these values and can change the info before ordering for the item.I don't want that.So is there any way to make these variables non-editable while displaying in service catalog,so that values of these variable will remain read-only and no one can edit it except system admin?
Please suggest me the way to do that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 01:51 AM
Hi Ishaan,
You may use Catalog UI Policies to make them read only.
More info here:
http://wiki.servicenow.com/index.php?title=Service_Catalog_UI_Policy#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 02:23 AM
Hi Regina,
If I will add other new catalog items with variables also then how will UI Policy work for them, as it can only apply on one catalog item.Catalog items and variables will keep on adding through web service and I want this thing only for catalog items which are adding through my script without affecting globally.I don't want to add UI policy for recently catalog item adding through web servicw again and again, as it will be like tiresome work for me.
Is there any way so that if like all my catalog items will have a same category, so that I can differentiate and then make variables of those catalog items as non editable ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 04:05 AM
Hey Ishaan,
You can use the following script :
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
post me your feedback
Please Hit ✅Correct, âÂ��Helpful, or ��Like depending on the impact of the response
Have a lovely day ahead
Regards,
Divya Mishra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2017 05:02 AM
Hey Divya,
Thanks for your response.Script is working fine.
But there is one problem.As client script is applicable only on particular catalog item for which it is defined.But I want to define it for all the catalog items which have a category "test".And I don't want to define a client script for each catalog item.Is it possible?