- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-12-2015 01:11 AM
Need to personalize form layout for CI forms. Need to pull some fields and rearrange it for all the CI Class. The problem is we have more than 100 class in CI table. Need to open all the CI forms and changing it will be a tedious work. Is it any easy way to personalize form layout that will affect all the CI class globally.
Not by the normal way (Right clicking the form header and configure--> form layout and pull the fields from there should affect all the CI Class globally)
Thanks,
Alad.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2015 02:00 AM
Hi Anto,
I have converted above code to Script Include.
You need to call this script include from background script.
Script Include Name is 'u_CIFormUtil'. Script include function accepts 3 parameters. Source Class table name, Target class table name, and sys_ids of UI sections of target table which is to be made == to source table.
var u_CIFormUtil = Class.create();
u_CIFormUtil.prototype = {
initialize: function() {
},
//This script will add the fields to the default view of the extended table . You need to customize the default view of base table like 'cmdb_ci_server'
// Once you are done with adding all the fields on default view of the base table, run this script by passing sys_id of the 'sys_ui_section' of the extended table.
CIUICaption: function(sourceTable, targetTable, targetTableUISectionSysID){
var gr = new GlideRecord('sys_ui_element');
gr.addQuery('sys_ui_section.caption',''); //
gr.addQuery('sys_ui_section.name',sourceTable); // base class to query
gr.query();
while(gr.next())
{
gs.print('Element Name: ' + gr.element + ' ' + 'Position: ' + gr.position);
//gs.print(gr.sys_ui_section.name);
//gs.print(gr.sys_ui_section.view);
var count = 0;
var child = new GlideRecord('sys_ui_element');
child.addQuery('sys_ui_section.caption','');
child.addQuery('sys_ui_section.name',targetTable); // extended table fields check
child.addQuery('element',gr.element);
child.query();
while(child.next()) // if found then aling the position of the fields to that of base table
{
gs.print('old pos: ' + child.position + ' ' + child.element);
child.position = gr.position;
child.update();
//var UIsec = new GlideRecord('sys_ui_section');
//UIsec.get(child.sys_ui_section);
//UIsec.update();
gs.print('new pos child : ' + child.position + ' parent pos : ' + gr.position + ' ' + child.element + ' ' + gr.element);
count++;
}
if(count ==0) // if field (element) does not found on the default view, then add it. Also align the element position to that of element position of base table
{
var addChildField = new GlideRecord('sys_ui_element');
addChildField.initialize();
addChildField.sys_ui_section = targetTableUISectionSysID; // sys_id of the UI section of the extended table which is to make same as base table UI section
addChildField.element = gr.element;
addChildField.position = gr.position;
addChildField.type = gr.type;
addChildField.insert();
addChildField.sys_ui_section.update();
//var UIsec1 = new GlideRecord('sys_ui_section');
// UIsec1.get(addChildField.sys_ui_section);
//UIsec1.update();
//var updateView = addChildField.sys_ui_section.view.getRecord();
//updateView.update();
gs.print('Added fields' + addChildField.element + ' ' + addChildField.position);
}
}
},
type: 'u_CIFormUtil'
};
Below code you have to write down in script backgrounds
var sourceTableArray = ['cmdb_ci_server']; // all source tables can be listed in array
var targetTableArray = ['cmdb_ci_linux_server'];// all target tables can be listed here in array
var targetTableUISectionArray = ['5f815e5fc0a8010e009bab06a8515bc9']; // all sys_ids can be listed for UI section of target table
var obj = new u_CIFormUtil();
for(var j = 0 ; j < sourceTableArray.length; j++)
{
gs.print('in loop');
obj.CIUICaption(sourceTableArray[j] ,targetTableArray[j],targetTableUISectionArray[j]);
}
Also, to export all the tables UI sections sys_ids, you can put below URL in your browser.
https:// instaceName.service-now.com/sys_ui_section.do?CSV&sysparm_default_export_fields=all
Kindly test this in Demo or dev instance. This should work.
Kindly mark this as helpful / correct answer if you don't have any other follow up questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2015 12:19 AM
Deepak thanks a lot for spending time for me and the script. its working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2015 12:21 AM
Welcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2015 07:19 AM
Your user name and password would be the same as your HI user name and password.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-17-2015 03:53 AM
thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2015 05:51 PM
Have you been able to use the mass update form tool?
It is perfect for bulk updating forms.
Please let me know if you need help with the usage. I'm confident that it solves your business problem.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022