Customer Portal

Get Involved. Join the Conversation.

Topic

    Qing Liu
    Show/hide page content based on SLA
    Topic posted August 10, 2010 by Qing LiuGold Medal: 3,500+ Points, last edited October 29, 2011 
    6246 Views, 37 Comments
    Title:
    Show/hide page content based on SLA
    Content:

    Hi All,


    The manual of Nov 2009 indicates we can hide page content with an SLA condition. Cool, but I test rn condition tag; it does not seem to work for me.


     Here is my test code:


    <rn:condition sla="internal_US" >


    <p>The content is only showing to Agents who have internal US SLA</p> </rn:condition>.


    As I read from community (https://cloudcustomerconnect.oracle.com/posts/26403dc734), the rn:condition SLA will only check SLA options, like  <rn:condition sla="selfservice">, <rn:condition sla="incident"> etc. It will not check SLA ID.


    If that is true, how we can show/hide contents on end users page based on SLA ID?  In my case, internal_US(17), internal_UK(18) both get different SLA ID.


    Is it some simply way to do like


    <rn:condition sla_id="17">,


    Show to US people


    </rn:condition>


    <rn:condition sla_id="18">,


    Show to UK people


    </rn:condition>


    I also look at SlaDiv widget, I found out that it also only reads SLA options


    Thanks you,  I am looking forward to your reply

    Comment

    • ksmithSerSol

      I would also love a solution for this.  We have a case where we have a specific organization that has access to a very limited number of answers, but we don't want them to see other parts of our site.  The <rn:condition sla> tag is pretty useless in this case.  Being able to specify an actual SLA name would be perfect.

    • Qing Liu

      After I read the thread in here(https://cloudcustomerconnect.oracle.com/posts/554194739a), I am starting to build a customized widget that  show/hide content based on the SLA ID.


      The code in action would be something like:


      In my controller.php:


      // Check the current customers c_id


      $CI = get_instance();


      $CI->load->model('standard/Contact_model');


      $contactID=$CI->session->getProfileData('c_id');


      //print_r($contactID);


      //Pass contact id to my customized model


      $CI2=get_instance();


      $CI2->load->model('custom/sla_model');


      $slaID=$CI2->sla_model->check_sla_id($contactID);


      In my customized model:


      <?php


      class sla_model extends Model


      {


          function sla_model()


          {


              parent::Model();


              //This model would be loaded by using $this->load->model('custom/sla_model');


          }


          function check_sla_id($contactID)


          {


              //In here, we try look up the SLA id for  the current logged in use


      $si = sql_prepare("SELECT sla_id


                FROM sla_instances, labels WHERE sla_instances.sla_id= labels.label_id AND contact_id=". contactID);


       sql_bind_col($si, 1, BIND_INT,  0);


             while($row = sql_fetch($query)) {


                          $results .= $row;


                      }


              sql_free($si);


              return $results;*/


          }


      }   


      If it is a correct way to implement, how we can make a join between sla.instance and contacts two tables? I was stuck in here. Any helps will be really appreciate.


      ----------------


      Btw, I also tried use standard incdient model to get SLA instances


      $ci2 = get_instance();


                      $ci2->load->model('standard/Incident_model');


                      $slaID= $ci2->Incident_model->getSlaInstances();


      Print_f (var_export($slaID));


      I got an empty array output: array()

    • jrinke

      I am also working on this, although I think you are farther along than I am.


      Monique responded to my post (https://cloudcustomerconnect.oracle.com/posts/554194739a) and said:


      "You can get the sla instances for the logged in user with $this->Incident_model->getSlaInstances()"


      I haven't been able to get that to work yet.


      We need this functionality to hide/display content and also to limit output of search widgets (<rn:widget path="search/ProductCategoryList" />) so they only show items the user's SLA ID allows.  That may be a different project.


      Keep us posted if you find a solution.


      Thanks!

    • Qing Liu

      Hi Jinke,

      I also want to have a SLA filter function like you want to have.  I guess I almost finish the function with customzied model, but I was stcuk in SQL query part. I do not know how to join sla_instance table with contact table. Because we can get current user contact ID and use it find out which SLA id the current user has.

      Regards,
      Qing

    • Andrew Prentis

      The SLA condition tag is meant for use within an answers/details page where an answer can be given an SLA or even parts of the answer given seperate SLA conditions so that only people with the correct SLA sees that portion of the answer.

      You are going about this the correct way by creating your own widget logic to check the SLA INSTANCE of a contact.

      SLAs can be very confusing - even the terminology can cause confusion :) I get into the habit of talking about SLA Instances when discussing the SLA granted to a contact rather than just using the term SLA. To me (and to the RN internals) an SLA is the definition of the SLA, while SLA instance refers to the particualr SLA granted to a contact.

      Anyway, back to the original question...

      To get the SLA instance details use this SQL:

      SELECT slai_id, sla_id, sla_set from sla_instances WHERE state=2 AND owner_id=$c_id

      slai_id  is the id of this particualr SLA instance (should you ever need to refer to it again

      sla_id is the id of the SLA (remember what I said before, ie the definition of the SLA).This ID will change if you edit the definiton of the SLA

      sla_set is another id for the SLA, however this id remains constant even if you edit the SLA definition.

      state=2 is specifying ACTIVE SLA instances. If a contacts SLA is changed or expired, the sla instances table will still contain that entry but its state will be change to 4 (for expired) or 3 (for deleted).

      Note on SLA ids: the sla_id of a particular SLA, for example lets assume we have an SLA called "Premium". When created with will have an sla_id and and sla_set allocated to it, eg sla_id=5 and sla_set=5. Now if at some point, we edit the SLA - for exampel change the name to "Premium Support", this will create a NEW SLA called "Premium Support" wth an sla_set=5 BUT sla_id=6. The old SLA "Premium" sla_id=5 will be set to inactive.

      So, if you wish to know which SLA a contact has, then you would use sla_set to identify the SLA. However if you wanted to look up the exact details of the SLA granted to the contact (ie the number of chat incidents they are allowed) you would want to check using sla_id.

      I hope all this makes sense...

    • Qing Liu

      Hi Andrew,

      Cool, thanks for the detail explanation. I execute your SQL query in my model, it seems work. I can get the slai_id, sla_id, sla_set values when users login to CP page.

      Correct me if I am wrong, Andrew. As I understand, if I wish to know which SLA a contact has, I will need use sla_set to identify the SLA. So I guess the id of sla_set is same as the id in service level agreements in RightNow console (Service configuration -> service level agreement )

      However, the id of sla_set from SQL query is different as the id of service level agreements showing in RightNow console.
      For instance, customer A is assigned by internal_US SLA instance in contact field. When he login the end user page, the outputs of SQL query:

      array ( 0 => 42, 1 => 19, 2 => 14, ) // slai_id, sla_id, sla_set

      But in my in service level agreements in RightNow console, internal_US has id is 21. Please see the attachment.

      How I can get the id in service level agreements in RightNow console by SQL query?

      Here is my customized model:

      $si= "SELECT slai_id, sla_id, sla_set from sla_instances WHERE state=2 AND owner_id=".$contactID;
      $query= sql_prepare($si);

      sql_bind_col($query, 1, BIND_INT, 0);
      sql_bind_col($query, 2, BIND_INT, 0);
      sql_bind_col($query, 3, BIND_INT, 0);
      $result=array();

      while($row = sql_fetch($query)) {
      $results [0]= $row[0];
      $results[1]= $row[1];
      $results[2]= $row[2];
      }
      sql_free($query);

      return $results;

      Thanks, I am looking forward to your early reply.

    • Andrew Prentis

      This is an instance where the sla_id of your internal_US has changed over time.

      Looking at your slas table, I can see id 19, 20 and 21 all belong to sla_set 14 BUT only sla_id=21 has the active flag set, so sla_id=19 is an old sla defintion. Any new contact granted this sla will be given an sla_id=21.

    • Qing Liu

      Hi Andrew,

      Thanks, I understand now. I manage to make my customized SLA id check widget work.

      In my controller of this widget:

      function getData()
          {
          // Check SLA function via model
          $CI = get_instance();
          $CI->load->model('standard/Contact_model');
          $contactID=$CI->session->getProfileData('c_id');
          //print_r($contactID);
          $CI2=get_instance();
          $CI2->load->model('custom/sla_model');
          $slaID=$CI2->sla_model->check_sla_id($contactID);
          $slaCheck =  $slaID[2];
          print_r($slaCheck);
          //Return SLAID       
          $this->data['slaID'] = $slaID;
          // which content to show up
          switch($slaCheck)
              {
                  case 14:
                      $display = 'US';
                      break;
                  case 13:
                      $display = 'EMEA';
                      break;
                  case 12:
                      $display = 'AU';
                      break;
              }
          $this->data['display']=$display;
          }

      View. php:


      <?if($this->data['display']=='AU'):?>
          This content is for AU
      <?elseif($this->data['display']=='EMEA'):?>
          This content is for EMEA
      <?elseif($this->data['display']=='US'):?>
              This content is for us
      <?endif;?>

      My follow up question is about what the best practise to use this SLA id check widget to filter out page content.

      I know we can nest widgets into a widget. Then it will make this SLAID filter widget become a long and complex view.

      I do not like that. It will be nice we can call the SLA id check function when we need it. Like in page template,

      if (slaid_check()== 'US'):

      {

      //then SHow US content

      }

      thanks


      Regards,

      Qing

    • ksmithSerSol

      Qing,

      Would you be willing to zip this custom widget and attach it here so I can try using it too?

      Thanks,

      ~Kelli

    • Qing Liu

      Hi ksmithSerSo,

      Sure, i can do that.   Here u go.  If you have questions, just ask.

      //Customized model

      <?php
      class sla_model extends Model
      {
          function sla_model()
          {
              parent::Model();
              //This model would be loaded by using $this->load->model('custom/sla_model');
          }

          function check_sla_id($contactID)
          {
              //This function would be run by using $this->sla_model->check_sla_id()
          
          $si = "SELECT slai_id, sla_id, sla_set from sla_instances WHERE state=2 AND owner_id=".$contactID;
          /*$si= "SELECT sla_instances.slai_id, sla_instances.sla_id, sla_instances.sla_set, contacts.c_id, contacts.first_name
      From sla_instances, contacts
      WHERE sla_instances.owner_id =29518956";*/

          $query= sql_prepare($si);
          
          sql_bind_col($query, 1, BIND_INT,  0);
          sql_bind_col($query, 2, BIND_INT,  0);
          sql_bind_col($query, 3, BIND_INT,  0);

             $result=array();

          while($row = sql_fetch($query)) {
                $results [0]= $row[0];
                $results[1]= $row[1];
                $results[2]= $row[2];
          }
             sql_free($query);
          //$results=20;
              return $results;
          }
          
      }    
       

      Regards,

      Qing

    • ksmithSerSol

      Thanks so much!

    • jrinke

      Qing and Andrew:

      Thanks to both of you for so much help on this question.  I am trying to modify Qing's code to work for my situation.  Qing's code works great as long as the customer has only one SLA (one sla_set).  In my case, a customer can have multiple sla_sets.  If a customer has SLA A, then they see content A.  If they have SLA B, they see content B.  If they have both SLA A and SLA B, then they see both content A and content B.  This is simplified - I actually have 4 SLAs, but you get the idea.

      How can I query to get all of the sla_sets for a customer?

      Also, is there a way to return a variable from the widget to the page?

      Then I think could display content on the page based on the value of the variable.  Qing's method requires that all of the conditional content be specified in the view.php for the widget.  That isn't going to work for me.  The content I want to be conditional are navigational tabs that are part of the template.  It's really back to Qing's comment:

      It will be nice we can call the SLA id check function when we need it. Like in page template,

      if (slaid_check()== 'US'):

      {

      //then SHow US content

      }

      Thanks for any ideas,

      Jim

    • ksmithSerSol

      Jim's post reminded me that I tried and failed to implement this code.  This is likely because I'm not a developer and none of it made any sense to me. :)

      If anyone would be at all willing to walk me through this step by step, I'll make my RN rep buy you a drink at the Summit next month.  Tongue out

    • jrinke

      Kelli:

      I would be happy to help you.  Send me an e-mail: jerinke@tmw.com

      -- Jim --

    • ksmithSerSol

      Email sent, Jim.  Thanks!!