Use PDIs? Take our 5-minute survey to help shape the PDI roadmap.

SOW form view mandatory field and internal notes query

sharsha
Giga Contributor

1. The required field should be made red asterisks, can we make them red colored? Please refer attached.
2. Internal Notes section is yellow in color in ITIL view as per screenshot attached.
Can we make them same colored style in SOW view. Thanks!
Please advise!

2 ACCEPTED SOLUTIONS

@sharsha 

 

g_form.setSectionDisplay() is supported in Service Operations Workspace, so the API itself should work.

I can see two potential issues in your implementation.

1. Remove the URL check first.
Your script checks top.location.href for now/sow. I would not use the URL to determine whether the form is running in SOW, because current Workspace record routes do not always contain that value, and access to top/window can also be affected by Client Script isolation.

Configure the Client Script for the SOW form view instead and test:

function onLoad() {
    console.log(JSON.stringify(g_form.getSectionNames()));
    g_form.setSectionDisplay('assignment', false);
}

 

getSectionNames() will show the exact section identifier available on that form, so please confirm that assignment is actually returned.

2. Check mandatory fields inside the Assignment section.
In your New Incident screenshot, Assignment group appears to be mandatory and empty. ServiceNow will not hide a section containing an empty mandatory field, otherwise the user would have no way to populate the mandatory value.

If Assignment Group is populated automatically by assignment logic and does not need to be entered by the agent, you would need to remove the client-side mandatory requirement before hiding the section:

 

 
function onLoad() {
    g_form.setMandatory('assignment_group', false);
    g_form.setMandatory('assigned_to', false);
    g_form.setSectionDisplay('assignment', false);
}

 

Only do this if the field is populated/validated elsewhere.

Also note that SOW uses two different form views:

Service Operations Workspace
→ existing Incident Details form

Service Operations Workspace New Record
→ Create New Incident form

If the Assignment section should always be hidden rather than conditionally hidden, I would not use a Client Script. Configure both of those views under Configure → Form Layout and remove the Assignment fields/section from the respective SOW views. That is the cleaner OOTB approach.

 

If my response helped, please mark it as correct and close the thread, this helps future readers find the solution faster!!!

View solution in original post

@sharsha ,

Have a try on below script once,

function onLoad() {
    var currentView = g_form.getViewName();
    if (currentView == 'sow' || currentView == 'sow_new_record') {
        g_form.setSectionDisplay('assignment', false);
    }


}

If my response helped, mark it as helpful and accept the solution.

Thanks,

Dinesh

View solution in original post

50 REPLIES 50

Hi @sharsha ,

Use the following script to hide the assignment section in SOW,

function onLoad() {
    //Type appropriate comment here, and begin script below
    var url = top.location.href;
    if (url.indexOf('/sow/record/incident')!=-1) {

        g_form.setSectionDisplay('assignment', false);
    }


}

If my response helped, mark it as helpful and accept the solution.

Thanks,

Dinesh