Refresh Declarative Actions Record conditions - UI Builder

Hugo12
Tera Expert

I have an Activity Action on a playbook. Record conditions are set and when the activity loads the those conditions work fine. I then trigger a modal and perform some actions that update the record in the background. Those updates should trigger the button to hide. If click update or refresh the page the button hides as expected. Is there anyway to trigger the declarative actions to refresh ad recheck the record conditions on demand? I tried the EVALUATE DECLARATIVE ACTION CLIENT CONDITIONS and BOOTSTRAP DECLARATIVE ACTIONS event handlers but they doesn't seem to work.

 

The OOB Update declarative action does seem to perform that recheck of the conditions. So mimic that behavior would be ideal. The issue is that the only thing that action does is current.update();

 

Any ideas?

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Hugo12 

Did you manage a workaround for this?

I am also facing the same.

I have a UI action which sets reference field on form via playbook User Form activity. But it seems when it refreshes it still shows empty value and doesn't reflect the database view.

But when I refresh the browser tab and url it reflects fine.

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

@Ankur Bawiskar, for that you can use the refreshRequested property of the Form component. Create a new refreshRequested Client State Parameter and point to it in the refreshRequested property of the Form component (under configuration). Then when you trigger that update make sure to also update the client state parameter to Date.now()  using the script option of the Update client state parameter event handler. It should work for you. There's a bunch of community posts explaining more about that parameter, you can easily google to get more info.
But will be something like this:

function handler({api, event, helpers, imports}) {
    api.setState("listRefreshRequested", Date.now());
}

This doesn't solve my issue though. I ended up triggering an update on the record via script, which causes the form to load. This way it seems the actions revaluate the conditions and worked for me. Would like to have another solution, so I'm still open to suggestions.
Hope I could help. 

@Hugo12 

Can you please share your solution & script along with screenshots

Thanks, I am not an expert though. If you could share screenshots of yours it would be great.

What I did is this

1) created playbook action

AnkurBawiskar_0-1728666514788.png

 

AnkurBawiskar_1-1728666535801.png

 

2) created new activity definition similar to OOB User Form and linked the above action to it

3) then used the new User Form activity definition on the playbook

My playbook runs on Table A and the form I am rendering is from Table B and the button is on form which shows up Table B record.

When I hit the button it does update in backend/native but it doesn't show the latest updated value on User Form activity. It shows this message.

AnkurBawiskar_2-1728667526791.png

 

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

I think this should trigger the form to reload. I would remove the action.openGlideRecord line. If you look at the OOB Update action it just does current.update and that triggers the form to reload. If it's reloading the form, something else is wrong but I'm not sure how to debug that.