How to omit a new button by setting condition's in omit new condition from a related list?

TechLead_vikas
Tera Contributor

Hi All,

Currently I am using Helsinki version of SNOW, in this version we have a Advanced list control with scripts.

When I am trying to omit a New button of a Related List using script for a Closed state condition, it is hiding for closed state as well as rest of the states.

The thing is, it is hiding in each state otherwise it is visible in each state.

I am using below script, please see the attached screen.

find_real_file.png

Please if you get my issue, let me know the solution.

Thanks,

Vikas Ambulgekar

1 ACCEPTED SOLUTION

veena_kvkk88
Mega Guru

I think you need to give answer; at the end. Like this: (From Helsinki Product Documentation: Advanced list control with scripts )



var answer ;


if (current.u_state=='Closed') { //Do not remove the 'New' button


  answer = false ;


}


else { //Remove the 'New' button


  answer = true ;


}


answer ;



If that doesn't work, use parent object in place of current like said in the doc. I'm not an expert but this is how I would try.


View solution in original post

9 REPLIES 9

snowtech1
Tera Expert

Try,



var answer=false;


if(current.u_state=='Closed') //Make sure Closed is the state 'name'


{answer=true;}


veena_kvkk88
Mega Guru

I think you need to give answer; at the end. Like this: (From Helsinki Product Documentation: Advanced list control with scripts )



var answer ;


if (current.u_state=='Closed') { //Do not remove the 'New' button


  answer = false ;


}


else { //Remove the 'New' button


  answer = true ;


}


answer ;



If that doesn't work, use parent object in place of current like said in the doc. I'm not an expert but this is how I would try.


TechLead_vikas
Tera Contributor

Thanks Veena



First I tried using current object but it's not worked, so I tried using parent object now it's working.



Thanks everyone


Linhart
ServiceNow Employee
ServiceNow Employee

use parent instead of current, works fine !!