locked
enable rule for subgrid RRS feed

  • Question

  • Hi,

    I have problem with enable rule on subgrid. It should enable/disable my custom Stop button based on status of the entity which is called Relation.

    My rule is defined like this (I used ribbon workbench):

          <EnableRule Id="new.new_relation.Stop.EnableRule">
            <OrRule>
              <Or>
                <ValueRule Field="statuscode" Value="100000000" />
              </Or>
              <Or>
                <ValueRule Field="statuscode" Value="100000001" />
              </Or>
            </OrRule>
          </EnableRule>
    

    So when I go from Account to see my record from Relation entity, my Stop button is enabled.
    But when I go from Request to see the same record from the Relation entity, my Stop button is disabled.

    What am I doing wrong?

    Thursday, June 27, 2013 8:18 AM

Answers

  • Hi,

    In the EnableButton JavaScript function pass parameters containing selected records ID (you can pass the parameters using Ribbon work bench) and then use JSON to retrieve field's value and based on that enable/disable the button. (I could send you a link on retrieving values from other records through JSON if you want.)

    Regards 

    Darrel

    Please mark as answer if it solved your query or vote for me if it helped you.


    • Edited by Darrel Dcosta Thursday, June 27, 2013 9:08 AM Grammar
    • Proposed as answer by Darrel Dcosta Thursday, June 27, 2013 12:15 PM
    • Marked as answer by mimamar Wednesday, July 31, 2013 7:35 AM
    Thursday, June 27, 2013 9:06 AM

All replies

  • Hi,

    I faced the same issue while using Ribbon workbench. It works well if there's just one condition.
    Work around would be is to Add an EnableRule <CustomAction> tag and assign a JavaScript function returning true or false to accomplish your requirements.
    eg. 

    function EnableButton(){

    var enable = true;

    If(Condition){enable = true;}

    else{enable = false;}

    return enable;

    }

    Regards,

    Darrel

    Please mark as answer if it solved your query or vote for me if it helped you.


    • Edited by Darrel Dcosta Thursday, June 27, 2013 8:54 AM Added example
    Thursday, June 27, 2013 8:52 AM
  • yes, but how to access the selected record to check the status of that record?
    Thursday, June 27, 2013 9:00 AM
  • Hi,

    In the EnableButton JavaScript function pass parameters containing selected records ID (you can pass the parameters using Ribbon work bench) and then use JSON to retrieve field's value and based on that enable/disable the button. (I could send you a link on retrieving values from other records through JSON if you want.)

    Regards 

    Darrel

    Please mark as answer if it solved your query or vote for me if it helped you.


    • Edited by Darrel Dcosta Thursday, June 27, 2013 9:08 AM Grammar
    • Proposed as answer by Darrel Dcosta Thursday, June 27, 2013 12:15 PM
    • Marked as answer by mimamar Wednesday, July 31, 2013 7:35 AM
    Thursday, June 27, 2013 9:06 AM
  • Hi,

    Darrel is right - ValueRules are not supported by Dynamics CRM in SubGrids. This isn't a limitation of the Ribbon Workbench - it's just that the ribbon commands don't support using ValueRules in this way - they only work on the form.

    I think I'll add a warning into the next version of the Ribbon Workbench indicating this if you try to use them in this way.

    You will need to use the SOAP/REST endpoint to retrieve the values of the selected records using a Custom Rule.

    How to pass the selected records:

     http://ribbonworkbench.uservoice.com/knowledgebase/articles/129783-pass-the-currently-selected-grid-row-s-to-a-custo

    How to use SDK to get values of records in Javascirpt:

    http://msdn.microsoft.com/en-us/library/gg334427.aspx

    hth


    Scott Durow
    Blog www.develop1.net    Follow Me
    Rockstar365
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Thursday, June 27, 2013 11:17 AM
    Answerer
  • Hi,

    Is this query answered? If so please do mark as answer or vote as helpful so that we could earn our points and be motivated to help others.

    Darrel,

    Thursday, July 4, 2013 8:19 AM