How to disable UI Action in Related List

loteodor
Kilo Contributor


Hi,

I would like to disable the UI Action 'New' on a Related List when a particular field of the main table has a specific value.

Have a look at the screenshot below here (in red the Ui Action).

I have a table 'Budget' with a related List of 'Budget Item' (or cost items) and I would like to disable the UI Action 'New' when the field Budget Sottomesso is equal to 'Si',   namely the budget has been submitted.

Thank you,

LorenzoMod Budget.png

19 REPLIES 19

Hi Lorenzo,


You can do it by List control itself but it will run Server Side so you need to save the form after value Si in Budget field.



find_real_file.png



answer = true means Omit New button



Also you can refer : http://wiki.servicenow.com/index.php?title=Personalizing_Lists#List_Control



Thanks,


Darshan


Hi Darshan,


I am trying with your method and i wrote the code below , but it doesn't work:



var answer;


if(parent.u_budget_sottomesso == "No"){


  //Do not remove the 'Edit' button


  answer=false;


}


else{


  //Remove the 'Edit' button


  answer=true;


}


answer;



Should i put something special instead of answer?


Like   document.getElementById("sysverb_new").style.display='none'?;



On the wiki Personalizing Lists - ServiceNow Wiki


it is written about he code above: ' if the script evaluates to true, the item is omitted.'.



I have multiple Related List in my page, if I will go on with this solution I have to write the same omit new condition script for every of my related list... I   can't believe that Service Now doesn't offer a functionality for disabling the entire display items with a condition :S


Hi Lorenzo,



To remove edit button you have write this with Omit Edit Condition field and not Omit New condition field.


Personalize your form layout ant get that field IN


And also remember keep Omit Edit button field unchecked.



For New button, make use of Omit New Condition and Omit New button fields


loteodor
Kilo Contributor

Thank you, now it works but you have to omit the last istruction 'answer' or you get an error of sintax.



Still looking for someone that knows a better solution in case I have 50 related list



Thank you to everyone for the support guys!


Hi Lorenzo,



It works and regarding that you have to add this explicitly to each Related List table   then Yes you ned to add it in each record of it.



Reason as this is each individual table which is related to current table.


If in your case there are 50 related list then I think you can write "Create ACL" only to admin


for all those.This can solve your problem.



Also there can be possible solution for this using HTML DOM methods.But it is not best practice to use as in future with upgrades and patches it may affect your script.



Thanks,


Darshan