Integrations and APIs for Service

Get Involved. Join the Conversation.

Comments

  • Sebastiaan Draaisma

    Yes you can.
    Depending on which field you want to use you could create an alias. See an example of this below:

    $incident_id = $rows[0][0]->val;

    $roql_result = RightNow\Connect\v1_3\ROQL::query( "SELECT Incident.ReferenceNumber, Incident.StatusWithType.Status.LookupName as Status FROM Incident WHERE Incident.ID =".$incident_id )->next();
    while($data =  $roql_result->next())
    {
    $rows[0][1]->val = $data['ReferenceNumber'];
    $rows[0][2]->val = $data['Status'];
    }

    In this example: Incident.StatusWithType.Status.LookupName
    Will be converted to an alias (a variable if you would like)

    Incident.StatusWithType.Status.LookupName as Status

    Status is the new name and equals Incident.StatusWithType.Status.LookupName

    This can then be used in the result set
    $rows[0][2]->val = $data['Status'];

  • Joseph Mastriano

    Thanks Sebastiaan!  This looks to be what I was looking for.

    With the ROQL query you posted, do you know if this can this be appended to the end of a REST call to return results? 

    Joe

  • Sebastiaan Draaisma

    Hi Joe.

    You can use the CCOM explorer which has most fields (not all of them).
    https://YOURSITE.custhelp.com/ci/admin/explorer/

    All fields can be found in the Common Object section inside the user doc for Connect PHP
    http://documentation.custhelp.com/euf/assets/devdocs/cloud19a/Connect_PHP/Default.htm

    As for the ROQL query, try the LIKE operator with the % wildcard
    SELECT Contact.Name.First, Contact.Name.Last, Emails.EmailList.Address FROM Contact WHERE Emails.EmailList.Address LIKE '%cgi.com'

     

  • Joseph Mastriano

    Hi Lakshay,

    That link to the documentation is api documentation that accesses Contact, however most of it is by id.  We will not know the id so using the ?q=emails.address='user@company.com' will allow a search using the email.address. 

    However, I have no idea as to where to find the actual fields in the query I can use to search contact.  So for instance if I want to search by a contact phone, or address how do I know what the target fields are?

    Where do I get that level of information?

    Thanks!

    Joe

     

  • Mike

    Thank you Lakshay,

    Unfortunately my CPM scripting knowledge is limited. Would you happen to have an example of this report with the custom script that would achieve this? 

  • Wouter Willemse

    Maybe a silly idea, but we're seeing a similar issue on creating contacts/incidents via API on a testsite which is a sparse clone. On a full clone, it works without issue.

    If you check the logs, under Error Log, you will find more detail on the error. In our case it indicates a violation in creating unique IDs in the DB, so it seems the sparse clone creation breaks something there.

  • Lakshay Bhalla

    You can delete the attachements in bulk using a custom script with the help of a report which lists all you Incident ID, Ref no and a third column with definition like group_concat(fattach.file_id,',').In this report add filters to be specific for those incidents you wanna delete. In this Custom Script you can use the REST API to perform the bulk delete in a loop for each row of that report. In Custom script you will first loop through each incident ID and then next you will loop through each File Attachement ID (as these are having comma as seprator, You can deseprate them in php easily).

    Thanks.

    -Lakshay

  • Lakshay Bhalla

    Hi Joseph,

    Look at this Documentation, It might help:

    https://docs.oracle.com/en/cloud/saas/service/18a/cxsvc/api-contacts.html

    Thanks

  • Nigel Oliver

    Thanks Sebastiaan,

    In the end we have returned the categories as an array and used in_array()

    // Get Cat list
    $aCatIds = array();
    if($incident->Category && $incident->Category->ID) {
    $aCatIds[] = $incident->Category->ID;
     
    foreach($incident->Category->CategoryHierarchy as $oCategory) {
    $aCatIds[] = $oCategory->ID;
    }
    }
     
    if (in_array(581, $aCatIds, true) {
    echo 'matched 586';
    }
     
    Cheers
     
    Nigel
  • Sebastiaan Draaisma

    Hi Nigel.

    I noticed a typo in

    $parCatID = £incident->Category->Parents->ID; // should probably be $

    In ROQL this is:

    • Incident.Product.Parent.ID
    • Incident.Category.Parent.ID

    The PHP Connect documentation states

    Named ID that holds a hierarchical value (e.g., ServiceProduct). It is similar to a NamedID, but the parent hierarchy is provided as a convenience for retrieval and to allow for the disambiguation of leaf names if they are not unique.

    NamedIDHierarchy is used primarily for identifying objects in the system that are not in the Connect Common Object Model (e.g., folders).

    For Parents (plural) I see the following text

    List of the parents of the entry, in order from root to immediate parent

    So it seems (not tested) to give you the complete path (from level 1 to the level you are in) so you may need to extract the level 1 only before you can assign it to the level 1 parent.

  • Rajan Davis

    I think you should be able to stringify the object literal without pushing it into an array.

    Also, I think your issue comes from setting the address type to an id of 0. If you POST the JSON without it being in an array, I think this problem will go away.

    Try this:

    function createContactRecord(sessionToken,email,fname,lname,custid,Brand)
    {    
        var obj = {
            name : {
                first: fname,
                last: lname
            },
            emails:{
                addressType:{
                    id: 0
                },
                address:email
            },
            customFields:{
                c:{
                     cf_session_brand:{
                        lookupName: Brand
                     },
                     cf_session_market:{
                        lookupName: SessionMarket
                     }
                 }
             }
        };
    
        return $.ajax({
              url: globalContext.getInterfaceServiceUrl('rest')+'/connect/v1.3/contacts',
              method: "POST",
              headers:{'Authorization':'Session '+sessionToken},
              data: JSON.stringify(obj),
              dataType: "json"
        });
    }
    
  • Mike

    Hi Rajan, Do you happen to have this CPM in PHP format ? 

  • Lakshay Bhalla

    Sathya,

    It appears to be piece of code being used in Some Extension. Are you Creating an Extension to create Contact? Or Could you explain the requirement if possible?

    Thanks

  • Sathya Rajendran

    Hi Lakshay,

    See my below code.

    function createContactRecord(sessionToken,email,fname,lname,custid,Brand)
    {    
        var obj=[];      
            obj.push({
                name :{
                    first: fname,
                    last: lname
                },
                emails:{
                    addressType:{
                        id: 0
                    },
                    address:email
                },
                customFields:{
                    c:{
                    cf_session_brand:{
                         lookupName: Brand
                    },
                    cf_session_market:{
                             lookupName: SessionMarket
                        }
                }
                }
             });
                     
        return $.ajax({
              url: globalContext.getInterfaceServiceUrl('rest')+'/connect/v1.3/contacts',
              method: "POST",
              headers:{'Authorization':'Session '+sessionToken},
              data: JSON.stringify(obj),
              dataType: "json"
            });
    }

  • Lakshay Bhalla

    Hi Sathya,

    Can you please post the piece of code you are using to save the contact for analysis?

    Thanks