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

@Dinesh Chilaka Value is 'sow', PFA.

sharsha_0-1786106596275.png

 

@sharsha ,

Did you guys configure anything from UI Builder for Service Operations Workspace?

Thanks,

Dinesh

@Dinesh Chilaka Nothing that I found in UI builder, anything in specific?
Could you please let me know if the same code is working for you in your instances, for Service Operation Workspace? Please check , Thanks!
As I mentioned before the same onload client script works for my Native/UI16/classic UI view.

@Dinesh Chilaka Nothing that I found in UI builder, anything do I need to check in specific, in the UI builder?
Could you please let me know if the same code is working for you in your instances, for Service Operation Workspace? Please check , Thanks!
As I mentioned before the same onload client script works for my Native/UI16/classic UI view.

@sharsha ,

Yes the same code has worked for Service Operations Workspace in my instance.
From UI Builder Check did anyone copied the Record Page and gave another view to render in Workspace or Did anyone configured Workspace view rules?
Ok, let's have a try this script whether it will hide the assignment group section in all places and then we can decide which view is rendering in the workspace.

function onLoad() {

        g_form.setSectionDisplay('assignment', false);
   


}

Just try above script, it will hide assignment section from every place ,just to make sure whether it is hiding in the workspace or not.
If my response helped, mark it as helpful and accept the solution.

Thanks,

Dinesh