System Admin and Configuration

Get Involved. Join the Conversation.

Topic

    James B
    Contact Certificate Flag on Incident WorkspaceAnswered
    Topic posted January 8, 2019 by James BBlue Ribbon: 750+ Points 
    41 Views, 10 Comments
    Title:
    Contact Certificate Flag on Incident Workspace
    Content:

    Hi all,

    We recently got email encryption enabled on our site using a workaround, since there has been a product defect identified within release 17D (this also prevents us from using the signed option). We have set our agents to use the "encrypt where possible" setting and its been working fine. However, we actually have no idea when composing a response if it is going to be encrypted or not.

    I have looked into adding a flag using the contacts.cert field. But for some reason, this is not accessible by the business rules, workspace rules and cannot be implemented into a workspace as a field either. It seems like it is only exposed to analytics. So my first question is, am I wrong here? If it can be looked up in any rule set it would be preferable to the solution I come up with below.

    In order to get this flag onto the incident workspace, I created a report that looks up the contact ID, with a simple IF expression and plugged it into the workspace. This works but the only annoyance is that it also loads the filter into the report and a lot of empty space. So my second question is, is there a way of making this look cleaner (image attached)?

    Thanks!

    Image:

    Best Comment

    Sebastiaan Draaisma

    The filter section does not have to be visible if you are intending to only show information related to the contact you have open. In that case you can use the contact id in a filter and the workspace will insert the id automatically for you.

    I'm not sure if I understood the icon prt correctly but you are able to use an exception or conditional format in combination with webding font to show/hide a padlock icon. Alternatively have a non functional padlock picture button in your workspace that you show/hide through a workspace rule.

    If you are unfamiliar with custom processes (I'm no expert on these myself) you are able to create a report with a custom script that sets the value of a custom field for contacts indicating if your contact has received a cert. You could use the file attachment table for this and have the report running scheduled behind the scene which will than update the custom field which you could than place in your workspace instead of the report component. So basically you have a report outside your workspace doing the work and you just use the custom field inside your workspace.

    If you are unfamiliar with custom script and just want a quick solution than I would remove the docked search filter and use the contact id as a filter and have the workspace insert this automatically for me.

    Comment

     

    • Sebastiaan Draaisma

      The search section seems unessecarry since you can use the primary key in your report, this will safe your agents some copy & paste + click.

      You could write a custom process that stores data (received Yes/No) in a custom field and have this field available in business rules and in your workspace.

      • James B

        Hi Sebastiaan,

        The report pulls the contact ID automatically using the report behaviour settings so there is no need for making a CPM to do this. Which is good, since I have no idea how to even write a CPM! I've been meaning to learn but never had the time. I just don't want the filter section to be viewable at all and make everything as compact as possible.

        My original plan was to unhide a padlock icon if the certificate is present, but since the API is not exposed to that field I can't do so :(

    • Sebastiaan Draaisma

      The filter section does not have to be visible if you are intending to only show information related to the contact you have open. In that case you can use the contact id in a filter and the workspace will insert the id automatically for you.

      I'm not sure if I understood the icon prt correctly but you are able to use an exception or conditional format in combination with webding font to show/hide a padlock icon. Alternatively have a non functional padlock picture button in your workspace that you show/hide through a workspace rule.

      If you are unfamiliar with custom processes (I'm no expert on these myself) you are able to create a report with a custom script that sets the value of a custom field for contacts indicating if your contact has received a cert. You could use the file attachment table for this and have the report running scheduled behind the scene which will than update the custom field which you could than place in your workspace instead of the report component. So basically you have a report outside your workspace doing the work and you just use the custom field inside your workspace.

      If you are unfamiliar with custom script and just want a quick solution than I would remove the docked search filter and use the contact id as a filter and have the workspace insert this automatically for me.

      • James B

        My initial plan was to insert a non functioning icon into the workspace and control it with rules. But, with the field not accessible by either ruleset I couldn't do that so I went with this reporting option. It took a bit of fiddling but we managed to get it to work without the search function in there with the steps below (thanks to my TAM to helping out with this):

        I initially just had the filter on the contact ID. If this filter was hidden the report would force us to insert a value that would overwrite the workspace value.
        We tried fixing it by adding the incidents table to the report as the root table, joining it to contacts. This didn’t work.
        We then tried fixing it by adding incidents.i_id as a hidden field. This didn’t work.
        We then fixed it by changing the filter to look at incidents.i_id AND having the incident.i_id as a hidden field.

        The only thing that's annoying me now is the dead space below the result that comes with inserting reports into workspaces (see image). If anybody knows of how to get rid of that, please be my guest to help out. But functionally speaking, this is now working. I may revisit this with a CPM you mention in paragraph 3 though as that sounds wicked handy! If you know of any resources I could look at to learn CPMs I would very much appreciate it.

        Thanks!

    • Sebastiaan Draaisma

      Unfortunately the dead space is non configurable as the report component can't be adjusted in height which is a shame...

      I'm in the process myself of getting a better understanding of custom processes, it's similar to custom script but more advanced.
      Please have a look at https://cx.rightnow.com/app/answers/detail/a_id/5169

      Here you will find a link to the Custom Process section with sample code

    • Colby Ross

      I am with Sebastiaan that a custom field and CPM would be best.

      I also agree that you could use a report custom script to do the same thing. To take his suggestion one step further, you could actually have the report hidden in the workspace (no delay) and when a response is sent and the incident is saved, the custom field would generate a value for you. Once saved you could refresh the workspace to see the custom field value, or you could do a quick little browser window that shows the icon you are wanting since the javascript api has direct access to the database. I sometimes do this because if the workspace refreshes before the value is saved, it may not show up on the workspae and another refresh would be needed to see it.

      • James B

        I started looking into this soon after because updating from reports is something I've wanted to do for a long time. I managed to yoink some code and trying to get it to work but to no avail. I'm pretty much just stabbing in the dark here:

        Initialisation
        require_once(get_cfg_var('doc_root')."/ConnectPHP/Connect_init.php");
        initConnectAPI();

        Process
        // Define variables

        $contact_id = $rows[0][0] -> val;
        $contact = RightNow\Connect\v1_2\Contact::fetch($contact_id);

        // Update the contact with the value calculated within the Certificate field.

        $contact->CustomFields->c->cert_received = $rows[0][2]->val;
        $contact->save();

        I'll keep digging into this as I would much rather update a field with this on a schedule every night, and have the rules reference that, than use a report on the workspace.

    • James B

      After 2 days of messing around in the bits of downtime I get, I seem to have a PHP code that can update a custom field in a contact record from a report. As others have said, the next logical step would be to implement this into a CPM. You can see it below with my breakdown:

      // Define variables
      $contact_id = $rows[0][0]->val;
      $contact = RightNow\Connect\v1_2\Contact::fetch($contact_id);
      $cert_flag = $rows[0][2]->val;
       
      // Update the contact with the value calculated within the Certificate field.
      if($cert_flag == "Yes") {
      $contact->CustomFields->c->cert_received = 1;
      $contact->save();
      }
       
      For people that may come across this thread years down the road and are as clueless as me, I'll break this down a bit.
      The first half is where I define my variables. A variable in PHP is denoted by the use of a $ before a word and is not case sensitive. You also do not need to define the variable type as far as I know, as PHP treats everything as a variant.
       
      First I created the variable $contact_id and assigned it to the first column in my report. When dealing with two dimensional arrays within reporting, it is important to make sure that the row (the first value within the []) is always set to 0 unless you know what you're doing.
      Next I assign the contact record for that row to the $contact variable. I never would have figured this bit out on my own, but basically this line fetches the contact record we define in $contact_id, so when we want to update the contact we can just use this variable instead of the whole line of code.
      Finally, out of my own habits I created the variable $cert_flag for the certificate flag value found in the third column of the report. This makes it easier to reference later and is generally good practice in code.
       
      Moving onto the actual update part, I start by using an IF statement to check that the $cert_flag value in the third column is set to yes (in PHP using a == means you are checking. A single = means you are setting the value). This saves on processing time as the update code will not run if it doesn't need to.
      I define the contact field i want to update by following the chain using -> to keep digging to the area I want. It's almost like how file directories work. I did have to steal this bit from another forum post so I knew where I was going since I am unfamiliar with it.
      I tell the code to set this value to 1. Why? Because my field is a Yes/No type and needs a boolean input. 0 = No and 1 = Yes. I have no idea what No Value is though.
      Finally, we save the record and close the IF statement.
       
      For a PHP pro this is all painfully obvious, but I hope I have helped someone who is on the same level as me achieve something.
       
      Cheers to all those who have helped me in this thread.
      • Sebastiaan Draaisma

        Well done Jaay! :-)
        Now you know the basics you will soon find yourself experimenting more with custom scripts and since it's PHP you will be able to use google to tacklemost of your problems. As allways... just reach out if any aditional help is required! :-)