Customer Portal

Get Involved. Join the Conversation.

Topic

    Janusz Jasinski
    How to display IDs and values for a customisable menu - not...Answered
    Topic posted March 15, 2019 by Janusz JasinskiBronze Crown: 15,000+ Points 
    101 Views, 4 Comments
    Title:
    How to display IDs and values for a customisable menu - not ROQL
    Content:

    Hi,

    I have a customisable menu called dm.classrooms along with getNamedValues but I keep getting the error as below. Any advice?

    Fatal error: Uncaught exception 'RightNow\Connect\v1_4\ConnectAPIError' with message 'Invalid propertyPath: Not a ConnectPHP class

    Best Comment

    Rajan Davis

    I would use this reference guide for seeing what classes are accessible.

    Once you have the correct reference to your Custom Object, you should be able to do the following (an ajax controller example):

    function getReasonsReturned(){
     
    $data = array();
    $menuItemValues = RNCPHP\ConnectAPI::getNamedValues("RightNow\\Connect\\v1_3\\<Your custom object here>\\<menu field name>");
    foreach ($menuItemValues as $key => $value) {
    $data[$key]['rr_id'] = $value->ID;
    $data[$key]['reason_returned'] = $value->LookupName;
    }
    echo json_encode($data);
    }

    Make sure that your menu is deployed and also that you are working with a menu field. I just tested the above and it worked so let me know if there's anything not working as expected.

    Comment

     

    • Sebastiaan Draaisma

      I normally just do this in a report (attached)
      I'm not sure how to do this through API. I think it will read like an array (like email addresses)

      $email = $contact->Emails->fetch( 1 );
      $email = $contact->Emails->fetch(“Alternate Email 1”);
      
    • Rajan Davis

      I would use this reference guide for seeing what classes are accessible.

      Once you have the correct reference to your Custom Object, you should be able to do the following (an ajax controller example):

      function getReasonsReturned(){
       
      $data = array();
      $menuItemValues = RNCPHP\ConnectAPI::getNamedValues("RightNow\\Connect\\v1_3\\<Your custom object here>\\<menu field name>");
      foreach ($menuItemValues as $key => $value) {
      $data[$key]['rr_id'] = $value->ID;
      $data[$key]['reason_returned'] = $value->LookupName;
      }
      echo json_encode($data);
      }

      Make sure that your menu is deployed and also that you are working with a menu field. I just tested the above and it worked so let me know if there's anything not working as expected.

      • Darsen Prasad

        Is there a way we can sort this by DisplayOrder ? rather than doing it after fetching

        • Rajan Davis

          I am not sure how to access the DisplayOrder of a custom object menu (it didn't come up when I checked), but I think if you could, you could modify the above code in the following way:

          function getReasonsReturned(){
          $data = array();
          $menuItemValues = RNCPHP\ConnectAPI::getNamedValues("RightNow\\Connect\\v1_3\\<Your custom object here>\\<menu field name>");
          foreach ($menuItemValues as $key => $value) {
                $index = isset($value->DisplayOrder) ? $value->DisplayOrder : $key;
          $data[$index]['rr_id'] = $value->ID;
          $data[$index]['reason_returned'] = $value->LookupName;
          }
          ksort($data); // sorts array by keys
          echo json_encode($data);
          }