locked
Enable Rule in RIbbon workbench RRS feed

  • Question

  • Folks,

    I need to enable ribbon based on some conditon, for tat am using enable rule in ribbon workbench.

    Below is the code to enable rule, 

           

    function enableRibbon()
    {
       
       var status = Xrm.Page.getAttribute("status").getValue();
       if(status == 3)
       {
       var lookup = new Array();
        lookup = Xrm.Page.getAttribute("feedback").getValue();
    if (lookup != null && lookup != undefined) {
            //alert("1");
            var name = lookup[0].name;
            //alert(name);
            var id = lookup[0].id;
            //alert(id);
            var entityType = lookup[0].entityType;

       var serverUrl = "/" + Xrm.Page.context.getOrgUniqueName();    //context.getServerUrl();
       var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc";
      
       var ODATA_EntityCollection = "/feebbackrationSet(guid'" + id + "')";
       var CRMObject = new Object();
       var jsonEntity = window.JSON.stringify(CRMObject);  // Define attribute values for the CRM object
               //Asynchronous AJAX function to Create a CRM record using OData
                $.ajax(
    {
       type: "GET",
       url: serverUrl + ODATA_ENDPOINT + ODATA_EntityCollection,
       data: {},
       contentType: "application/json; charset=utf-8",
       dataType: "json",
       async: false,
       success: function (result) 
    {
           if (result != "undefined" && result.d != "undefined" && result.d.results != "undefined" && result.d.results != "undefined") 
    {
               var lengthResult = result.d.results.length;
    //alert(lengthResult);
               if (lengthResult > 0)
    {
    var satbool= result.d.results[0].satisfaction;

    if (satbool== true)
                                  {

      return false;
     }
     else
     {

      return true;
     }
                        }
                    }
    }
            });
     }
    else
     {

     return false;
     }
    }

    this is not working if i cal tis in ribbon workbench.


    • Edited by shree k Friday, July 10, 2015 10:07 AM
    Friday, July 10, 2015 10:07 AM

All replies

  • HI , 

    Can you able to debug your code. 

     Check weather itz returning true or false.

     

    Sunday, July 12, 2015 4:26 PM
  • you need to make sure that the Schema Names of the fields and entities are correct.



    My blog: www.crmanswers.net - CRM Theme Generator

    Monday, July 13, 2015 2:08 AM
  • I am able to debug the code and it s returing true or false.Problem am facing here is in fetching lookup value. but in form onload it s working fine and the same code in ribbon workbench it s not working.

    We have upgraded our ribbon workbench to 2.0.0.7.

    in 2.0.05 we didnt face any issue like this.

    Monday, July 13, 2015 10:28 AM