Announcements
I have created custom action to generate sor code on Account entity in dynamics CRM. I am calling this custom action from ribbon button using XRM.webapi.execute . Ribbon button has display rule javascript code to hide the button when SOR code field contains data...we are updating the account sor code in custom action. We are able to refresh the form but when ribbon button is still displayed even though SOR code field has data populated from custom action plugin code...how to fix this?
The Core Issue:
Xrm.WebApi.execute
is asynchronous. Your ribbon display rule JavaScript runs before the custom action updates the SOR code field.
The Solution: Force Ribbon Re-evaluation
The most reliable way to solve this is to force a re-evaluation of the ribbon after your custom action completes and the form is refreshed.
Here's the JavaScript you should use:
Key Points:
Xrm.Utility.forceControlRefresh();
: This is the crucial line. It tells Dynamics 365 to re-evaluate all ribbon button display rules.Xrm.Utility.forceControlRefresh();
is called after the formContext.data.refresh()
promise resolves. This ensures the ribbon is re-evaluated with the updated data.Why This Works:
Xrm.Utility.forceControlRefresh();
forces Dynamics 365 to run the display rule's JavaScript again.Troubleshooting:
If you are still experiencing issues, please provide the following information:
This additional information will help me provide more specific troubleshooting guidance.
André Arnaud de Cal...
293,639
Super User 2025 Season 1
Martin Dráb
232,663
Most Valuable Professional
nmaenpaa
101,158
Moderator