How to create a new section through scripting

subrata_mettle
Kilo Contributor

I am trying to creating a new section for the incident .

Didn't find any method or object for creating the new section through scripting in ServiceNow.

find_real_file.png

Also I have a queries about the field selection.

When I am selecting any field within a scripts which is under the selected section in the image, I am able to get the field details.

But didn't get the field details which are available under "Available" section   within the same scripts, why so?

if I want to take any kind of action on the "Availability" fields (left in the image), like visibility/label etc through " g_form" object then how I will able to do that through scripts.

Thanks !!!

Regards

Subrata

4 REPLIES 4

Harneet Sital
Mega Sage
Mega Sage

Hi Subrata,



For your first query there is a table in ServiceNow which stores all the sections and their availability of forms, sys_ui_section so you can use any scripts available to make new entries on this table.



For you second query you can refer GlideForm (g form) - ServiceNow Wiki   wherein all the function related to g_form api are available which includes setting mandatory/ visibility/ label.


Thanks Harneet for your quick response,


I will check the sys_ui_section option..



I have gone through the scripts link already for the second question.



As I mentioned , I am able to do the all the stuff like mandatory/ visibility/ label. through scripting only if the field are under the "Selected"   section.(Plz refer the image)



If the same command i am going to use for the fields which are under the "Available" section , I am getting "undefined" error for that field.


my question is how i can make those fields are available under the g_form API



Thanks and Regards,


Subrata


Subrata,



g_form is a client side API so when you use the functions defined on this API the field needs to be present on the form. Now there are two sections on the form layout, the ones in the selected list are actually present on the form and hence can be accessed from the g_form API, but the available list contains which aren't yet on the form they are available but aren't on the form so cannot be accessed with a client script since they were not loaded on the client side from the server itself. So when you try to access it the error of undefined pops up because browser cannot find any information related to fields which were not loaded in the first place.



Hope this clarifies your question.


Yes Harneet, that's ok but point is I wanted to make that fields available within the form through scripting.


As I was trying to buil one App where new fields will be available but also that fields need to be show on the page.



As a ServiceNow admin/itil user we can make the selection changes by configuring on the page.


If we will able to provide the selection within the page at the time of loading then End user doesn't need to bother about the selection mechanism , whenever they will click the page , they can see the fields too.



is there any way to set the specific fields available for the page ?



Hope so I am able to point out the exact requirement.



Thanks and Regards,


Subrata