How to update a related list, list control record with background script to remove "Edit" button based on some condition.

Pravallika14
Tera Contributor

Hello Team,

I have few related lists on few Ticketing Modules. .and I want to remove "Edit" button on one of the related list on HR Form, based on some condition. For EX: if the ticket state is transferred, The below related list should not have "Edit" button available.

find_real_file.png

I tried to update the List control record directly by giving the "omit Edit condition" .however due to Application scopes vs Record scope mismatches , I could not save the record with my changes.

find_real_file.png

find_real_file.png

Hence , I wanted to remove the "Edit" button using a background script. Can someone please help me how can I write a background script to remove "Edit" button based on the below condition.

var answer;

if(parent.state == 9)
{
answer =true;
}
else{
answer = false;
}

 

Hi @Ankur Bawiskar ,

Could you please check and assist on this.

1 ACCEPTED SOLUTION

Hi,

you can try to check that as well in condition by getting the parent class name

Regards
Ankur

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

View solution in original post

6 REPLIES 6

Elena Pomana
Tera Guru

Hello,

 

I think it would be easier to copy the OOTB UI action "Edit..." and to apply the conditions that you need on it.

It depends on how many related lists you want to have the logic applied.

 

Have a great one,

Elena

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

If it's not allowing then as mentioned by @Elena Pomana you can try to override the OOB button and update the condition field

Regards
Ankur

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

Pravallika14
Tera Contributor

Thanks @Elena Pomana, @Ankur Bawiskar ,

But, could not get what I have to really need to do. Are you talking about the below UI action.?. I am not sure, how to edit the scripting part to achieve this requirement. can you please suggest me a simple way if we have any .

find_real_file.png

Hi,

change the table name to m2m_kb_task and do insert and Stay

Then update the condition of UI action so that it hides when ticket state is transferred,

Regards
Ankur

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