I have a requirement to show the form section 'self serve' tab to show only when opened

Trupti Krishnam
Tera Contributor

I have a requirement to show the form section 'self serve' tab to show only when opened through a specific record producer.called 'Mac Systems' i have created a form section on dmn_demand table .Please help me in achieving this requirement

 

TruptiKrishnam_0-1755752975820.png

Help me to hide this section in the form when it is opened through a specific record producer.

1 ACCEPTED SOLUTION

@Trupti Krishnam 

did you add log and see what came in that scratchpad variable?

is the section name correct? underscore etc

how are you testing?

1) you should test 1 Demand submitted by record producer Mac Systems

2) another submission of Demand by some other record producer

function onLoad() {

    // give correct section name
    alert('value->' + g_scratchpad.isValid);
    if (g_scratchpad.isValid == 'true')
        g_form.setSectionDisply('self_serve_variables', true);
    else
        g_form.setSectionDisply('self_serve_variables', false);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@Trupti Krishnam 

you can use this logic

1) display business rule on your table (dmn_demand)

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var gr = new GlideRecord("sc_item_produced_record");
    gr.addQuery("producer.name", "Mac Systems");
    gr.addQuery("task", current.sys_id);
    gr.query();
    g_scratchpad.isValid = gr.hasNext().toString();

})(current, previous);

Then

2) onLoad client script on your table (dmn_demand)

function onLoad() {

    // give correct section name
    if (g_scratchpad.isValid == 'true')
        g_form.setSectionDisply('self_serve_variables', true);
    else
        g_form.setSectionDisply('self_serve_variables', false);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Even i have tried the same scenario is not working

 

 

 

@Ankur Bawiskar it is not working even if i open other record producers still i can able to see it

@Trupti Krishnam 

did you add log and see what came in that scratchpad variable?

is the section name correct? underscore etc

how are you testing?

1) you should test 1 Demand submitted by record producer Mac Systems

2) another submission of Demand by some other record producer

function onLoad() {

    // give correct section name
    alert('value->' + g_scratchpad.isValid);
    if (g_scratchpad.isValid == 'true')
        g_form.setSectionDisply('self_serve_variables', true);
    else
        g_form.setSectionDisply('self_serve_variables', false);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader