Che Pazzo
ServiceNow Employee
ServiceNow Employee

I love scoped apps. They are (mostly) fantastic. However, I often find myself in a situation where the changes I want to make are not allowed due to different scopes. I have outlined two common issues with solutions that I tend to use with related lists on scoped table forms.

This behavior has been observed in the Orlando release and earlier.

enjoy.

Adding a related-list to a scoped table form.

The problemThe "Default" form view exists in the Global scope so you are not allowed to modify it.

Standard solution:

Create a new view just for your app

1. First, create a new view in your scope (there is a convenient link right there on the page when the platform complains about it).

Great! Now you've created the related-list.

But wait ... the only view available to you is the "Default" view.

2. Create the *exact same view* for your form.

Great! Now you can open an existing record, switch to your new view and the related list looks great!

As time goes on and you make changes to your form, you add them to this new view.

But wait ... now people are complaining that they can't see the new fields you've added so you have to tell them to change views.

3. Remove all fields from the "Default" view less a single annotation that instructs the user to "change view"

Great! Now people aren't bothering you (as much).

But wait ... now when someone tries to create a new record, the form only shows the annotation and the create-a-new-record for doesn't allow you to change the view!

4. Create the *exact same view* for the list-layout.

Great! Now things mostly work. It's a bit clunky having to keep changing views for your app, but at least there's a path forward.

 

The biggest annoyance is that when you start developing all of your apps as scoped, you are constantly having to change views. 

 

A Better Way:

This result is great, but the path is a bit convoluted.

1. Navigate to the "Default view": https://<instance>.service-now.com/sys_ui_view_list.do?sysparm_query=sys_scope%3Dglobal^title%3DDefault view


2. Click the "Related Lists" tab

3. Right-click the query path and select "Open in new window"

4. Click "New"

5. Type in the name of the table where you want to add related lists

6. Click "Submit"

7. Go back to your scoped table and select "Configure --> Related Lists"

8. You should now be able to add related lists to your form in "Default view" without having to create a bunch of new views for your app.

 

Updating List Control on a related-list on a scoped table form

The Problem: Trying to modify list-control (change tab label, etc) is basically impossible. 

Details

1. Right-click the hamburger menu on a column

2. Select "configure -> list control"

3. Modify something (e.g. change the label)

4. Sit and wait for a few minutes for things to time out

5. Throw something against the wall to vent your frustration for wasting 5m of your life.

 

The [terrible] Solution.

[non-obvious things are in purple in case you thought maybe I mistyped something (I did not)]

1. Make sure you are in the correct scoped update-set.

2. Open a background script editor: https://<instance>.service-now.com/sys.scripts.do

3. Set the scope to "global".

4. Execute this script:

var result = null;

// this is the table in your scope with the related list
var table_with_related_list = '<"Table" field on ListControl form>';

// this is the <related_table>.<ref_field>
var related_list_table = '<"Related list" field on ListControl form>';

// the display value for the Related-list Tab
var display_value = 'My Cool List';

try {
    var gr = new GlideRecord('sys_ui_list_control');
    gr.initialize();
    gr.setValue('name', table_with_related_list);
    gr.setValue('related_list', related_list_table);
    gr.setValue('label', display_value);
    result = gr.insert();
}
catch (error) {
    result = "ERROR: "+error+"\n"+error.stack;
}
gs.info(result);

4b.  (optional) To add the "Edit..." button:

var result = null;
var sysid = '<sys_id of the list_control record created in previous step>';

try {
    var gr = new GlideRecord('sys_ui_list_control');
    gr.get(sysid);
    var item = gr.related_list.toString();
    result = updateFloats(item);
}
catch (error) {
    result = "ERROR: "+error+"\n"+error.stack;
}
gs.info(result);

function updateFloats(item) {  
    var d = getDictionaryEntry(item);
    if (d == null)
        return;     
    d.reference_floats = true;
    d.update();
}

5. Click "Run Script"

 

Yeah, it's terrible, but it works. Hopefully, newer releases will improve this experience.

Version history
Last update:
‎10-16-2019 11:20 AM
Updated by: