How to Hide Declarative Action in Record List Component Based on Parent Record Field Value?

hamidouche
Giga Expert

Hello Community,

I'm trying to conditionally hide a Declarative Action ("New") in a Record List Component within a workspace based on the parent record's field value.

Setup:

  • Parent Table: x_parent_table (appears in workspace)
  • Child Table: x_child_table (related list via Record List Component)
  • Relationship: Child Table has a reference field cfem pointing to parent
  • Goal: Hide the "New" action when parent.stage = 'locked'

What I've Tried:

1. Client Conditions in Declarative Action:

  • The Action Model Fields dropdown doesn't include any parent or parentRecord field
  • Only shows fields from the Facilities table itself (query, count, groupBy, limit, page, etc.)
  • No access to parent record context

2. Script Condition in Declarative Action:

 
 
javascript
var cfemGR = new GlideRecord(childTable);
if (cfemGR.get(current.cfem)) {
    return cfemGR.getValue('stage') != 'locked';
}
return true;
  • current is not available in this context
  • Script condition doesn't execute or has no effect

Limitations Found:

  • Declarative Actions don't have access to current record in Script Conditions when used in Record List Components
  • Client Conditions Action Model doesn't expose parent record context
  • Cannot reference parent fields through the child relationship

Question:

How can I conditionally show/hide a Declarative Action in a Record List Component based on the parent record's field value?

Is this possible through:

  • UI Builder component configuration?
  • Client State Parameters?
  • A different approach entirely?

Any guidance or workarounds would be greatly appreciated!

5 REPLIES 5

Ankur Bawiskar
Tera Patron

@hamidouche 

I was able to hide Related List Button on sc_task based on RITM state. I used Server Script Type

Related list button shows when RITM belongs to Catalog Item Testing and not for others

May be you are using wrong field or value to compare for state

AnkurBawiskar_0-1768560083279.png

 

hide related list action based on parent field.gif

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@hamidouche 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi @Ankur Bawiskar ,

Thanks for taking the time to answer my question.

The problem I am having is not with any Declarative Action, it's specifically with New and I have to specify the following fields as follows:
- Action name: create-new-uxf

- Implemented as: UXF Action

-Specify client action: Create New Record

 

the last point is important. If I choose Implemented as : Server Script, I won't have access to the client action : Create a New record

 

Another problem is that my related list is a Record List Component, SN is pushing for its use in place of other related list components. but I don't understand why it does not give us access to parent or current in the condition script for example.

So yes, I can and I did hide other UA action/declarative actions before, but New is a tough one so far

 

Thanks,

Hamiduche

@hamidouche 

share your declarative action config screenshots

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