How to Hide Process flow based on condition

Madankumar N1
Tera Contributor

I Created custom flow formater for incident Process flow like Open,WIP,On Hold,resolved,Cancelled another one Software Category
if incident category is Software i dont want show software process in flow formatter

MadankumarN1_0-1676055208929.png

But still it showing how we can hide this one 

MadankumarN1_1-1676055274359.png

 

1 ACCEPTED SOLUTION

Shubham_Shinde
Giga Guru

Hello @Madankumar N1 ,

The Condition field in Flow Formatter record is used to highlight the flow formatter as active on given conditions, as mentioned on ServiceNow Docs:

Shubham_Shinde_0-1676058136445.png


However, if you want to hide the flow formatter you can achieve it by creating an onLoad Client Script on Incident table and use below script in it:
 if (g_form.getValue("category") == "software" && g_form.getValue("state")== 2){
       $j("a:contains('Software Category')").parent("li").hide(); //it checks for the anchor tag containing Software Category title and then hiding the parent li which is containing that anchor tag

}

Note: Make sure that Isolate Script is set to False for this client script.


If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

Regards,

Shubham

View solution in original post

3 REPLIES 3

Shubham_Shinde
Giga Guru

Hello @Madankumar N1 ,

The Condition field in Flow Formatter record is used to highlight the flow formatter as active on given conditions, as mentioned on ServiceNow Docs:

Shubham_Shinde_0-1676058136445.png


However, if you want to hide the flow formatter you can achieve it by creating an onLoad Client Script on Incident table and use below script in it:
 if (g_form.getValue("category") == "software" && g_form.getValue("state")== 2){
       $j("a:contains('Software Category')").parent("li").hide(); //it checks for the anchor tag containing Software Category title and then hiding the parent li which is containing that anchor tag

}

Note: Make sure that Isolate Script is set to False for this client script.


If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

Regards,

Shubham

Hey @Shubham_Shinde . This works! But I now have a scroll issue. 

 

This was the code I used:

function onLoad() {
    //Get the department value
    var department = g_form.getValue('department');
    // Define the department sys_id to check against
    var targetDepartmentSysId = '6de165b2db3a338438b5e415ca961966';

    // Define the formatters to hide based on the department value
    var formattersToHide = [];

    if (department == targetDepartmentSysId) {
        // Hide these formatters if the department matches the target sys_id
        formattersToHide = ['Initiating', 'Planning', 'Executing', 'Delivering', 'Closing'];
    } else {
        // Hide these formatters if the department does not match the target sys_id
        formattersToHide = ['Inception', 'Construction', 'Testing & Acceptance', 'Transition'];
    }

    // Hide the specified formatters using jQuery
    formattersToHide.forEach(function(formatter) {
        $j("a:contains('" + formatter + "')").parent("li").hide();
    });
 
This is the output when the dept does not match given sys id
 harinivenkatesh_1-1741342839773.png

 

 This is the output when the dept match's given sys id
harinivenkatesh_0-1741342801269.png

Any thoughts? 

 

Yousaf
Giga Sage

Hi Madankumar,
Please read the comments in this thread and let me know if its solves your problem
How to Hide Process flow based on condition 

 

Mark Correct and Helpful if it helps.


***Mark Correct or Helpful if it helps.***