Integrations and APIs for Service

Get Involved. Join the Conversation.

Comments

  • Chethana KM

    Hi,

    The business requirement is as follows:
    We have to display all the Regulation attribute values as a dropdown on Customer portal.
    User selects one of the Regulation, say - "abc" and clicks on "Download Report" button.
    This should download all the articles with Regulations attribute set to "abc"

    To achieve the above requirement, we are following the below steps in the code, making more than one API call inside loop:
    1. Firstly, we are hitting the Content REST API to get all the docIds existing in the Service cloud database
    2. For each DocId (obtained from Step#1), we are again hitting the Content API to search for the specific Regulatory attribute value inside the xml field of the article (in the REST API response). When we looped through the docIds, it was taking more time to process fetching of data. Then, to improve the performace, we are calling a function to implement multi curl to make more than one REST API call at a time. Still, the requests are getting executed sequentially only and the performance is not getting improved. Hence, we have thought of implementing parallel execution of multi-curl, for which we need the multi-threading concept/technique in Service Cloud.

    Request you to provide us some direction/suggestions on how to improve the performance on execution of REST API's parallely on Service cloud?

    Thanks,
    Chethana

     

  • Chethana KM
    Hi Robert, Thank you for the suggestions! I have the following queries: 1. I am not able to figure out how to query for attribute using search Rest API. From the documentation, I see that we can search for some keyword/text or filter further based on facets. Could you please advise how to configure search Rest Api to query for article attributes? 2. As you say, if we set an attribute as master identifier, it will be displayed along with title of the article on UI. This is fine if it doesn't impact the regular search functionality on Customer portal. Also, the attribute which we want to query through rest api is a data list in the schema. It can have values "abc", "xyz" and so on.. My another doubt is that, suppose for an article art1, if the value of attribute is "abc" and the title (another attribute) of the article is "xyz general text". Now, if we want to retrieve articles having regulations as "xyz" and use content api to query for "xyz" in the title, then the article art1 will be fetched in the content api results,even though it doesn't have "xyz" as regulations. If regulations value is present in title as well, then this will lead to wrong results and we cannot go with this approach of using content api. Please suggest. Thanks, Chethana
  • Robert Surujbhan

    Hi Chethana, at this time, when querying the /content API via GET calls like you are doing, it is not possible to filter articles with the “q” parameter using Attribute values (aka Schema Nodes, for a Content Type).  For now, the only way to do that is using the Search API which is the other REST API service with Knowledge Advanced (https://sitename-qp.custhelp.com/srt/api/latest...).

    With the Content API, one possible workaround is to configure your preferred content type Attributes to be part of the Master Identifier.  The full master identifier then becomes the Title of the record, and as you know, the ‘title’ field is queryable using the “q” parameter when you call GET on /content.  In summary, using the Master Identifier/Title is one way to query on article attribute values using the Content API.  Just be aware that all attributes designated as part of the master identifier are concatenated to form the complete title of the document/article - if you are OK with that for display purposes, you will be fine.

     

  • Venkatesh Reddy

    Can you please me out.

  • Mike Kramer

    Thank you sir!  That is the answer I was looking for!  Appreciate the help.

  • Chandra Prasad

    Hi Suresh,

       if (isset($obj->prev)) --> isn't throwing error but, the content inside 'if' condition is no getting executed as (isset($obj->prev)) is empty.

     

    Thanks,
    Chandra

  • Suresh Thirukoti

    I had this prev issue earlier so I tried below and it worked...so you can also try and check

     

     if (isset($obj)) {

     .....................

       if (isset($obj->prev)) {

    //assignment and further action on prev object

    }

    }

    ~Suresh

  • Lakshay Bhalla

    Hi Chandra,

    Please attach the Complete CPM for RCA.

    And i would suggest to use the Best Practices and Gotchas for CPMs such as Exception handling. Link: https://cx.rightnow.com/app/answers/detail/a_id/9640/track/AvM9zwqoDv8S~fPaGpRy~6LwenU6~S75Mv8O~zj~PP~H

    Use "\" in the catch like: catch(\Exception $ex).

    Thanks

    Lakshay

  • Chandra Prasad

    Hi Sristy,

    CPM is being triggered for Contact update.

    <?php
    /**
     * CPMObjectEventHandler: ContactHandler
     * Package: RN
     * Objects: Contact
     * Actions: Update
     * Version: 1.3
     * Purpose: CPM handler for contact create and update.
     */
     
    use \RightNow\Connect\v1_3 as RNCPHP;
    use \RightNow\CPM\v1 as RNCPM;
     
     
    class ContactHandler implements RNCPM\ObjectEventHandler
    {
     
        /**
         * Apply CPM logic to object.
         * @param int $runMode
         * @param int $action
         * @param object $obj
         * @param int $cycle
         */
        public static function apply($runMode, $action, $obj, $cycle)
        {
     
    $var1=$obj->Name->First;
    $var2=$obj->Name->Last;
     
    if (isset($obj))
        {
     
    $var1=$obj->Name->First;
    $var2=$obj->Name->Last;
       
    $pvar1=$obj->prev->Name->First;
    $pvar2=$obj->prev->Name->Last;
    if(isset($pvar1)){
            if ($var1 != $pvar1) {
    try{
                $custom1 = new RNCPHP\CO\CustomContact();
    $custom1->ContactID= $obj->ID;  
                $custom1->FieldName= "First Name";
            $custom1->FieldValue= $pvar1;
                $custom1->save(RNCPHP\RNObject::SuppressAll);
    }
     
                    catch (Exception $err ){
                        echo $err->getMessage();
                        }
    }}
    if(isset($pvar2)){
    if ($var2 != $pvar2) {
    try{
                $custom1 = new RNCPHP\CO\CustomContact();
    $custom1->ContactID= $obj->ID;  
                $custom1->FieldName= "Last Name";
            $custom1->FieldValue= $pvar2;
                $custom1->save(RNCPHP\RNObject::SuppressAll);
    }
     
                    catch (Exception $err ){
                        echo $err->getMessage();
                        }
            }
    }
     
     
        }   
    }
    }
     
     
     
    *CustomContact is a Custom object
     
    Thanks,
    Chandra
  • Sristy Arya

    Hi Chandra,

     

    Can you give some clarity : CPM is being triggered for Incident or Opportunities ?  If possible share the code to debug along with the field detail you are trying to access.

     

    Thanks

    Sristy  

  • Sergio Andres Barreto Valderrama

    Hello Robert,

    Thanks for answering.

    We need it to be an automatic process by ICS, do you know if there is an API to import data?

    thanks for your help!

  • Robert Surujbhan

    Hi Sergio - are you not able to use the Data Import Wizard for some reason?  If not, and you need to use an API approach, the Connect Web Services API (SOAP) can import up to 1000 records at a time in one request using its Create operation. 

    You can also create contacts using the REST API.

    How many contacts do you need to import?  Also, what will be the data source (e.g., a flat CSV text file of data you have stored locally)?

  • Robert Surujbhan

    Hi Mike, what you are describing is possible using a standard feature in the Service Cloud extensibility frameworks that can (1) fetch data from external systems and (2) display the results using Reports which you can then add to Workspaces just like any other Report.  The data is fetched in real-time and never stored in the OSvC database.

    When you build these integrations, "virtual tables" are exposed to the OSvC Report Designer GUI which allows you to manage them easily (arrange columns, add charts, etc.).  In your code, you define where the data comes from - in other words, you'd be responsible for populating the "virtual tables" using your middleware system via web service API calls, DB queries, etc. which get executed when the report is run/displayed/refreshed.  It's the perfect solution for what you described as read-only "standalone data".  These virtual tables wouldn't connect to any other object in the system.

    This feature works in both the Agent Browser UI web console or the .NET Agent Desktop console.  Which one are you using?  You'd have to build specialized virtual report add-ins/extensions respectively.  See the below documentation links for details!  If you need additional sample code, please let us know.

    https://documentation.custhelp.com/euf/assets/devdocs/unversioned/BUI_Extensibility/topicrefs/Analytics_for_External_Data.html

    https://documentation.custhelp.com/euf/assets/devdocs/unversioned/Connect_AddIn_Framework/Content/Desktop%20Add-In%20Framework%20API/Add-In%20Types/Read%20Write%20Report%20Add-Ins.htm

  • *** Chauhan

    Great. Do you have any link/page which I can refer to for creating vba code for role assignment? May be that would help me create similar code for password reset.

     

    Many thanks in advance!

    Regards,

    ***

  • Travis Crane

    I have not tested that but I know that you can add roles via excel vba so I would assume that if there is a REST API for password resets then it would work.