Posts

Posts

  • Gursimran Singh Saini
    RNCPHP\CommunityQuestionComment won't workAnswered1
    Topic posted January 3, 2019 by Gursimran Singh SainiGold Crown: 30,000+ Points, tagged Connect PHP in B2C Service > Integrations and APIs for Service public
    Title:
    RNCPHP\CommunityQuestionComment won't work
    Summary:
    Not able to use RNCPHP\CommunityQuestionComment in PHP API
    Content:

    PHP file stops working soon as it reaches any code with class RNCPHP\CommunityQuestionComment

    RNCPHP\CommunityQuestion and RNCPHP\CommunityUser works fine but RNCPHP\CommunityQuestionComment won't work.
     
    For example:
    echo "Before";
    $comment = new RNCPHP\CommunityQuestionComment();
    echo "After";
     
    The code won't reach "After".
     
    Have tried on different sites.
    Have tried on PHP API Version 3 and 4.
    Version:
    CPHP API 4
  • Kelvin Chung
    Detect user response incident email and trigger CPM PHP...35.0
    Topic posted December 21, 2018 by Kelvin ChungGreen Ribbon: 100+ Points, tagged Connect PHP, Custom Process Models - CPMs, SOAP in B2C Service > Integrations and APIs for Service public
    Title:
    Detect user response incident email and trigger CPM PHP curl to call web service
    Summary:
    Tigger PHP c
    Content:

    I am new to RNT and try to detect user response incident email and trigger CPM  to call web service. I am using PHP to get the change in an incident when user response email in the thread automatically without customer service representation involves by checking the old and new thread to see if there is any change. See code below. I already verify curl_exec() works for soap request on my service.

    Q1) Do you think above will work to detect user reply incident email?

    Q2) I use Execute Async option, will above automatic retry if curl_exec() fail to connect remote server?

    I can only test in debugging and not able to test in deploy. That's why I would like to verify before sending the code to deployment.

    I appreciate any help.

     

     

     

     

    Version:
    August 2017
    Code Snippet:
  • Bibek Jena
    XML Download15.0
    Topic posted December 19, 2018 by Bibek JenaGreen Ribbon: 100+ Points, tagged Connect PHP in B2C Service > Integrations and APIs for Service public
    Title:
    XML Download
    Summary:
    Download xml file to our local.
    Content:

    Hi All,

    i want to fetch the data from OsvC database and form a xml and download the same xml to my local folder.

    i was able to create a xml file ,but downloading the same file to my local is not working.

    Tried giving below headers for force download:

    header('Content-type: text/xml');
    header('Pragma: public');
    header('Cache-control: private');
    header('Content-Type: application/force-download');
    header('Content-Disposition: attachment; filename=test.xml');

    Not sure why i am not able to download xml file ,but this is what i tried for downloading .xls file which worked fine for me.

    Any help would be Appreciated.

    Thanks and Regards,

    Bibek Kumar Jena 

     

    Version:
    v1.3
    Code Snippet:
  • Sebastiaan Draaisma
    PHP array questionAnswered15.0
    Topic posted December 18, 2018 by Sebastiaan DraaismaBlack Diamond: 60,000+ Points, tagged Connect PHP in B2C Service > Integrations and APIs for Service public
    Title:
    PHP array question
    Content:

    I have a custom field for accounts (text area) that contains an array. I would like to report on these arrays. I created a report with a custom script in the process section

    // Output array count
    $var = $rows[0][0]->val;
    $array = settype($var, "array");
    $rows[0][1]->val = count($array);

    The thing is... it doesn't count the array content and I've tried a few different things...
    Hardcoding the array does seems to work so I'm not sure what I'm missing.

    // Output array count
    $array = array(1812,1811);
    $rows[0][1]->val = count($array);

    Version:
    18C
    Image:
  • Seethalakshmi S
    how to store custom text value in date/time custom field75.0
    Topic posted December 13, 2018 by Seethalakshmi SBronze Medal: 1,250+ Points, tagged Connect PHP, Custom Process Models - CPMs in B2C Service > Integrations and APIs for Service public
    Title:
    how to store custom text value in date/time custom field
    Summary:
    Store custom text value in date/time custom field
    Content:

    Hi All,

    In ROQL I have received date/time in string format. So I converted into date/time in (MM:DD:YYYY HH:MM") format.

    After that, I need to store the converted date/time value in "Date/time" datatype custom field.

    While I am trying to store the converted value in date/time datatype field, I am getting error like "Type Mismatch"

    How to resolve this?

    Thanks,

    Seethalakshmi

    Version:
    Version 18C
    Code Snippet:
  • Earl Taylor
    Synchronizing the SLA field with a Custom Object
    Topic posted December 11, 2018 by Earl Taylor, tagged Connect PHP, Custom Process Models - CPMs in B2C Service > Integrations and APIs for Service public
    Title:
    Synchronizing the SLA field with a Custom Object
    Summary:
    We want to change an existing script to sync with the SLA container for the orgs table
    Content:

    We have a script that updates our Custom Object fields from the Organization table. This has been working great, but now we need to add a field on the Custom Object and have the SLA container object synch with this new field. this new field is used to identify end user support status, when a partner opens an incident for the end user.

    We were hoping to just be able to add a line of code in this process to do this. The new field name in the CompanyName$CN Custom Object is "sup_tier"

    We have the SLA Container showing in the Oragnization Work space, but the value displayed is not actually present in the orgs table itself.

    Does anyone have an idea how this can be done? The SLA tables are a pain to deal with as it is. Any help would be appreciated.

    The current code is as follows:

    <?php

    /*
    * CPMObjectEventHandler: organization_create_update
    * Package: OracleServiceCloud
    * Objects: Organization
    * Actions: Create, Update
    * Version: 1.2
    * Purpose: Pushing Org data to CompanyName$CN CBO
    */

    // This object procedure binds to v1_2 of the Connect PHP API
    use \RightNow\Connect\v1_2 as RNCPHP;

    // This object procedure binds to the v1 interface of the process
    // designer
    use \RightNow\CPM\v1 as RNCPM;

    /**
     * An Object Event Handler must provide two classes:
     * - One with the same name as the CPMObjectEventHandler tag
     * above that implements the ObjectEventHandler interface.
     * - And one of the same name with a "_TestHarness" suffix
     * that implements the ObjectEventHandler_TestHarness interface.
     *
     * Each method must have an implementation.
     */

    class organization_create_update implements RNCPM\ObjectEventHandler
    {
        public static function apply($run_mode, $action, $obj, $n_cycles)
        {
            $debug = true;
           
                self::debugJsOutput($debug, $obj->ID, "***********\n");
                self::debugJsOutput($debug, $obj->ID, "***********\n");
                self::debugJsOutput($debug, $obj->ID, date("Y-m-d H:i:s") . "\n");
                self::debugJsOutput($debug, $obj->ID, "***********\n");
                self::debugJsOutput($debug, $obj->ID, "- " . __CLASS__ . "::" . __FUNCTION__ . "\n");
                self::debugJsOutput($debug, $obj->ID, "-- Action: " . ( $action === RNCPM\ActionUpdate ? "Update" : "Create" ) . "\n");
                self::debugJsOutput($debug, $obj->ID, "-- Cycle number: " . $n_cycles . "\n");
                self::debugJsOutput($debug, $obj->ID, "-- run_mode: " . $run_mode . "\n");
               
                if($run_mode == 1)
                {
                    $obj = RNCPHP\Organization::fetch($obj->ID);
                    self::debugJsOutput($debug, $obj->ID, "-- LookupName = " . $obj->LookupName . "\n");
                   
                    if(!is_null($obj->CustomFields->CompanyName->CN))
                    {
                        $CN = RNCPHP\CompanyName\CN::fetch($obj->CustomFields->CompanyName->CN->ID);
                        self::debugJsOutput($debug, $obj->ID, "-- CN = " . $obj->CustomFields->CompanyName->CN->ID . "\n");
                    }
                    else
                    {
                        $CN = new RNCPHP\CompanyName\CN();
                    }
                     
        if(!is_null($obj->CustomFields->c->sfdc_acctno))
                    {
                        $CN->SFDC_no = $obj->CustomFields->c->sfdc_acctno;
                    }
                    else
                    {
                        $CN->SFDC_no = 'FAKE-' . rand(100000,999999);
                    }
                       
                    $CN->Comp_name = $obj->LookupName;
        $CN->save();
                    self::debugJsOutput($debug, $obj->ID, "-- CN ID = " . $CN->ID . "\n");
                   
                    $md = $obj::getMetadata();
                    $cf_type_name = $md->CustomFields->type_name;
                    $md2 = $cf_type_name::getMetadata();
                    $obj->CustomFields->CompanyName = new $md2->CompanyName->type_name;
                    $obj->CustomFields->CompanyName->CN = $CN->ID;
                    //$obj->save();
        $obj->save(RNCPHP\RNObject::SuppressExternalEvents);
                   
                    self::debugJsOutput($debug, $obj->ID, "-- Saved.\n");
        
        $obj = RNCPHP\Organization::fetch($obj->ID);
                    self::debugJsOutput($debug, $obj->ID, "-- LookupName = " . $obj->LookupName . "\n");
                   
                }
           
            try
            {
                return true;
            }
            catch(Exception $e)
            {
                self::debugJsOutput($debug, $obj->ID, "-- Exception: " . $e->getMessage() . "\n");
            }
        } // apply()
       
        private static function debugJsOutput($debug, $id, $data)
        {
            if(!is_dir("/tmp/CompanyName"))
                mkdir("/tmp/CompanyName");
           
            ob_start();
           
            echo 'Org' . $id . ' ';
           
            if(is_object($data))
            {
                echo "<pre>";
                print_r($data);
                echo "</pre>";
            }
            else
            {
                echo $data;
            }
           
            if($debug)
            {
                echo ob_get_clean();
            }
            else
            {
                file_put_contents("/tmp/CompanyName/cpm_organization_" . date("Ymd") . ".log", ob_get_clean(), FILE_APPEND);
            }
      
        }
    } // class organization_create


    /*
    The Test Harness
    */
    class organization_create_update_TestHarness implements RNCPM\ObjectEventHandler_TestHarness
    {
        static $org_invented = NULL;
        static $CN_invented = NULL;
     
        public static function setup()
        {
            //$CN = new RNCPHP\CompanyName\CN;
      $org = new RNCPHP\Organization;
            static::$org_invented = $org;
            //static::$CN_invented = $CN;
            return;
        }

        public static function
        fetchObject( $action, $object_type )
        {
            // Return the object that we
            // want to test with.
            // You could also return an array of objects
            // to test more than one variation of an object.
            //return(static::$CN_invented);
      return(static::$org_invented);
        }

        public static function
        validate( $action, $object )
        {
            #return(!is_null(static::$CN_invented->ID));
            return $object;
        }

        public static function cleanup()
        {
            // Destroy every object invented
            // by this test.
            // Not necessary since in test
            // mode and nothing is committed,
            // but good practice if only to
            // document the side effects of
            // this test.
            return;
        }
    }

     

    Thanks

    Earl Taylor

    Version:
    Feb 2018 version
  • Sebastiaan Draaisma
    ROQL query on Profile table in report125.0
    Topic posted December 10, 2018 by Sebastiaan DraaismaBlack Diamond: 60,000+ Points, tagged Connect PHP in B2C Service > Integrations and APIs for Service public
    Title:
    ROQL query on Profile table in report
    Content:

    Hi there.

    I'm trying to get a ROQL query on the Profile table in a report.
    I found the following documentation

    The following example shows a ROQL query on the Profile managed table:
    SELECT * FROM Profile; DESCRIBE Profile;

    I tried the following custom script inside a report (report also attached)

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

    Process
    $profile_id = $rows[0][0]->val;

    //build the ROQL query using the profile id
    $query = "SELECT P.CreatedTime FROM Profile P WHERE P.ID=".$profile_id;

    //run the query
    $query_results = RightNow\Connect\v1_2\ROQL::query($query)->next();

    $row = $query_results->next();

    //put the results in the report
    $rows[0][1]->val = "Created ".$row['CreatedTime'];

     

    I don't get any result...
    (the code does work when performing a query on the incident table)

    I'm not sure if I'm missing something? smiley

    Image:
  • Padma Prabha Varadarajan
    Query in REST API Call1
    Topic posted December 6, 2018 by Padma Prabha VaradarajanRed Ribbon: 250+ Points, tagged Connect PHP, Custom Process Models - CPMs, REST in B2C Service > Integrations and APIs for Service public
    Title:
    Query in REST API Call
    Summary:
    Querying Currency code menu in Custom Object
    Content:

    Hi 

    We have a custom object and standard object related, and created a currency menu object (Standard object: Currencies) in the custom object. 

    Trying to fetch the currency lookupname using ROQL from the custom object.

    But we are getting the error saying "Currency is not a valid object"

    Able to fetch only the Currency ID and not the lookupname. 

    Also, when we try to use this field in standard object and do the ROQL the lookupname is fetched without any issue.

    Please provide some idea on the same 

     

    Thanks 

    Padma

    Version:
    Service Cloud 18B, 18C
  • Lautaro Illescas
    Add an image to a report in a custom process45.0
    Topic posted December 5, 2018 by Lautaro IllescasGreen Ribbon: 100+ Points, tagged Connect PHP, Custom Process Models - CPMs in B2C Service > Integrations and APIs for Service public
    Title:
    Add an image to a report in a custom process
    Content:

    Hi

    We have to execute a report from a custom process, and add to it a signature, wich is received as a PNG from another system. Then send it by mail as an attachment.

     From what we understand, we can easily execute the report from PHP, and we can also easily send it by mail. The problem is that we can't add the bytes of the signature to the report.

    We tried to replace the image dynamically from the report, but we had no success. We also tried to get a report with images from SOAP and REST, to tried to replace it, but we also had no sucess. Is it possible to make an image of the report and overlap the image of the signature? We tried this but we coudn't do it.

    We are open to ideas/suggestions.

    Please let me know if this is possible,

    Thanks.

  • Sebastiaan Draaisma
    Connect PHP transaction log entryAnswered7
    Topic posted December 4, 2018 by Sebastiaan DraaismaBlack Diamond: 60,000+ Points, tagged Connect PHP in B2C Service > Integrations and APIs for Service public
    Title:
    Connect PHP transaction log entry
    Summary:
    Create a transaction log entry through Connect PHP
    Content:

    Does anyone know if it's possible to use Connect PHP to create a custom log entry in the transaction table? I'm unable to find any documentation regarding this so I assume it's not possible but hope to be proven wrong :-)

    Version:
    18C