Skip to main content

Notifications

Microsoft Dynamics CRM forum
Answered

Ribbon Workbench value rule on grid only work if column is on grid

Posted on by 40

Hello,

I am trying to enable/display a smart button on the main gird (view)  of a table (entity).

I want it to be enabled if the selected row has certain criteria met.

I found that when using the value rule in the ribbon workbench this only works if the grid (view) has all the columns (fields) in the condition.

I tried to use a custom enable rule using the following code but it will not return the true value back to ribbon workbench to enable the button

pastedimage1645714410235v1.png

pastedimage1645714448834v2.png

CheckForecastView: function (selectedItems) {
  var gridContext = selectedItems[0].Id;
  var retVal = false;
  Xrm.WebApi.retrieveRecord("msdyn_customerasset", gridContext, "?$select=a, b, c").then(
  function success(result) {
    var a = result.a;
    var b = result.b;
    var c = result.c;
    if(a !== 809700000 && b !== 1 && (c === "SA" || c === "SA13")) {
      retVal = true;
    }
    else {
      retVal = false;
    }
  return retVal;
  });
},

  • anavrin Profile Picture
    anavrin 40 on at
    RE: Ribbon Workbench value rule on grid only work if column is on grid

    Bipin,

    This worked.

    Thank you very much!

    Regards,

    Patrick Nielsen

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: Ribbon Workbench value rule on grid only work if column is on grid

    Hi,

    Your code is working but it is not returning the correct result because XRM.WebApi.retrieveRecord executes as async process. You will need to use promise to evaluate the ribbon rule. Please see below blog -

    debajmecrm.com/.../

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans