Question

Struggling with disabling the action dynamically

Good day, Team!

 

I'd want to deactivate the section action dynamically based on the value retrieved from a database table.

 

The issue I'm having is with the getSectionActions function. When I try to obtain data using ESQ, ServiceHelper and as well as System setting, before my logic of disabling the action, I think actionMenuItem is returned. And the action isn't disabled as a result. Please look at the screenshot below and propose a method to make it work.

 

I am attaching the screenshot of all three scenarios : 

1. Using ESQ

 

 

 

2. Using ServiceHelper

 

 

 

3. Using System Setting

 

 



Many Thanks!

Like 1

Like

4 comments

Hi,

 

Please provide code parts not in screenshots, but the code itself and also describe your business task.

 

Thank you!

 

Best regards,

Oscar

Sarthak,

ESQ, calling service methods, getting a system setting, are all asynchronous methods. The getSectionActions method will not wait for your async callback to complete before it returns the result, so you are correct, it is returning before you get back the async result from one of these methods. You will have to rethink how the flow of things is working by possibly pre-fetching the items and caching locally so they are already available in the getSectionActions method.

Ryan

Ryan Farley,

 

Can you suggest us a possible way to pre-fetching the items and caching locally ?



Regards,

Sarthak Jain

Sarthak Jain,

That depends on where/when they need to be used. If you need them available as soon as the section opens, I'd fetch them somewhere else like the init of the MainHeaderSchema, which loads as part of the main application. You could cache them using the StorageUtilities module. See 

https://customerfx.com/article/persisting-data-between-pages-in-creatio…;

Hope this helps.

Ryan

Show all comments