Declarative action client conditions - how to add new action model fields

tbenbenisti
Tera Contributor

Hello,

 

I'm trying to create a new button on the SOW for the consumable assets list.

I want to make this button available only for certain assets, based on the asset status.

I want to achieve this using the client condition, but I'm not sure how to add a new action model field for the asset status and then utilize it in the condition set.

 

tbenbenisti_0-1793274571877.png

 

4 REPLIES 4

kmohammed
Tera Guru

Client Conditions can only use fields that are part of the action's Action Model, which is why the asset status field is not in the list yet.

 

On the declarative action record (the one in your screenshot), scroll to the Action Model Fields related list and add a new field for the consumable asset table, selecting the field that holds the asset status. Save, then reopen the Client Condition builder — the new field should now be available to choose, and you can set it to the status values you want the button to appear for.

 

Two things to check if it still does not appear:

- Make sure you added the field to this action's model, not to a different declarative action — each action has its own model fields.

- Client Conditions are evaluated in the client from the data the model provides, so a field that is not in the model cannot be used there. If you need a condition on a field you do not want in the model, use Record Conditions instead, which are evaluated server-side against the full record.

 

After adding the field, test on a consumable asset in each status to confirm the button shows and hides as expected.

Hi @kmohammed,
Thank you for your reply.
I'm not completely sure about the steps.
I created a new field on the related list, but what makes this field hold the value? Where is the mapping? At the moment, it's empty; I can't actually use this field

tbenbenisti_0-1793600390788.png

 

Hi @tbenbenisti, good question — and your screenshot shows exactly why it stays empty.

 

That related list is only a schema definition, not data. A row there (Label / Column name / Type) just declares "there is a field called u_install_status." Nothing writes a value into it afterwards, and there is no separate mapping screen to configure.

 

The value is supplied automatically at runtime ONLY for fields the action's payload already carries. Yours is a list action, so look at the other 8 rows in your screenshot: count, groupBy, table, query, limit, page, view and sysIds. That list context is all a list action receives — it is evaluated once for the whole list, and the platform does not fetch install_status from each row in the list and put it into the model. That is why the new field is empty and cannot be used in the Client Condition.

 

You have two workable options:

 

1. If the button should depend on ONE asset's status, make it a form (record) action instead of a list action. On a record, a model field whose Column name and Type exactly match a real field on that record's table (install_status) IS populated from the current record — that matching column name is the "mapping" — and the Client Condition can then use it.

 

2. If it must stay on the list, remove u_install_status from the Client Condition and do the check in the action's client script instead: take the selected sysIds from the payload, check those assets' install status (for example via a GlideAjax call to a Script Include), and only proceed when the selected record(s) are in an allowed status, otherwise show a message and stop.

 

So it is not a step you missed in the related list — a list action simply has no single asset status to populate that field with.

Vishal Jaswal
Tera Sage

Hello @tbenbenisti 

Here is an example:

VishalJaswal_0-1793649239179.png

 

VishalJaswal_1-1793649285292.png



Without record condition:

VishalJaswal_3-1793649340176.png

 



VishalJaswal_2-1793649332028.png