Integrations and APIs for Service

Get Involved. Join the Conversation.

Topic

    Mike Chelotti
    How to delete incidents using ROQLAnswered
    Topic posted November 28, 2018 by Mike ChelottiBlue Ribbon: 750+ Points, tagged Connect PHP 
    30 Views, 6 Comments
    Title:
    How to delete incidents using ROQL
    Summary:
    Attempting to use this code snippet to delete incident records?
    Content:
    Hi , I was reading through the ConnectPHP guide for Oracle 18A , I want to be able to delete records using this code snippet. Would I run this from the customer portal somehow? Or am I able to log into the CLI using OPC ? 
    
    
    
    Version:
    18A
    Image:
    Code Snippet:

    Best Comment

    Robert Surujbhan

    Hi Mike - no, that query area in the Connect Object Explorer is just an interface for running ROQL select statements, not PHP code.

    In Service Cloud, the only places to host and run PHP code and use the Connect PHP API would be:

    1. within the Customer Portal framework (controllers, models, views/pages, widgets, etc.)
    2. the custom scripts directory (content managed via File Manager and exposed via the /php/custom/* web path on an interface)
    3. a CPM object event handler
    4. in Analytics Reports (report scripts)

    Comment

     

    • Robert Surujbhan

      Hi Mike - no, that query area in the Connect Object Explorer is just an interface for running ROQL select statements, not PHP code.

      In Service Cloud, the only places to host and run PHP code and use the Connect PHP API would be:

      1. within the Customer Portal framework (controllers, models, views/pages, widgets, etc.)
      2. the custom scripts directory (content managed via File Manager and exposed via the /php/custom/* web path on an interface)
      3. a CPM object event handler
      4. in Analytics Reports (report scripts)
    • Rajan Davis

      Also, to add on to what Robert is listing here, if you go the ConnectPHP or REST API route of deleting incidents using ROQL, make sure that you specify that you are using CCOM v1.4 and also specify an application context.

      Here is the reference documentation:

      1. ConnectPHP

      2. REST API

      Hope this helps,

      Raj

    • Mike Chelotti

      There are some decent examples in the REST API Guide but the GUIDE doesn't show you any working examples and assumes you know what to enter after query=

      Moreover how do you get the record ID for an incident by the the LookupName for example 180614-000013 

      
      }
      
      https://your_site_interface/services/rest/connect/version/queryResults/?query=semicolon-separated ROQL DELETE 
      

      When I tried https://interface.custhelp.com/services/rest/connect/v1.3/queryResults/?query=11635%20ROQL%20DELETE%20queries

      I got a response 

       

      {
          "type": "https://interface.custhelp.com/services/rest/connect/exceptions/OSC-CREST-00019",
          "title": "Invalid query parameter value",
          "status": 400,
          "detail": "This query is not supported: near \"11635\": syntax error",
          "instance": "https://interface.custhelp.com/services/rest/connect/v1.3/queryResults/?query=11635%20ROQL%20DELETE%20queries",
          "o:errorCode": "OSC-CREST-00019"
      }
      

       

      Can you provide me with an example on how to delete a single incident ? Or do you have any cheatsheet of working examples ? 

       

      Thank you. 

      • Rajan Davis

        Mike,

        The documentation that I posted above has examples of how to perform the DELETE operations.

        With that said, looking at your request that you have posted, there are a couple of things that stand out:

        1. You need to change the CCOM version to 'v1.4' or 'latest' in order to use the DELETE operation. Your URL needs to start with either of the following:
          1. https://interface.custhelp.com/services/rest/connect/v1.4/
            
          2. https://interface.custhelp.com/services/rest/connect/latest/
            
        2. Your query looks malformed; it needs to be formatted like the following:
          1. https://interface.custhelp.com/services/rest/connect/v1.4/queryResults/?query=DELETE%20FROM%20incidents%20WHERE%20referenceNumber%20=%20'180614-000013'
            
        3. As I have mentioned above, because you are using a CCOM version 1.4, you need to send a special header.

        As far as working examples, I have built a few wrappers for the REST API. I have examples for running DELETE requests in the terminal or in scripts using the following languages/environments:

        1. Node/Javascript
        2. Python (both 2 and 3)
        3. PHP (both 5.6 and 7)
        4. C#
        5. For use in the terminal (Supported on Linux, Windows and OSX)

        I would modify your query first; however, should you need help with any of the wrappers feel free to ping me here and I will do my best to help you out.

        Kind Regards,

        Raj

    • Mike Chelotti

      Thanks Raj, this is pretty awesome! Well done.