Configure an Object Function for Cancel Action Plan

You must configure an object function for canceling action plan.

Following are the steps:

  1. Sign in to Oracle CX Sales using Administrator role.

  2. Navigate to Application Composer.

  3. Go to Service Request > Server Scripts.

  4. Go to Object Functions tab.

  5. Click New icon to add a new object function.

  6. Provide the function name as CancelProcess.

  7. Enter the following groovy code:

    def conn = adf.webServices.ReadTaskIdBySR
      
    try{
      def task = conn.GET("Cancel SR:"+SrNumber)
      def taskId = task["items"]["number"].toString()
      def len = length(taskId)
      
      println("taskId: "+taskId +len) 
      
      if (len <3)
      {
        println("error finding cancel task")
        def msg='There is no activate action plan for this SR.'
        throw new oracle.jbo.ValidationException(msg)
      }
      
      taskId = right(left(taskId, len-1), len -2)
      println("taskId: "+taskId) 
      
      def action=[
          "action": [ "id": "SUBMIT",  "type": "SYSTEM"]
        ]
      
      conn = adf.webServices.InvokeCancelTask
      
      def result = conn.PUT(taskId, action)
      println("Status:"+conn.statusCode)
      
      //set SR status field value  to 'Cancelled'
      setAttribute('StatusCd', 'SVC_CANCELLED')
      setAttribute('ProcessStatus_c', 'CANCELLED')
       
      println("Setting SR status to Cancelled")
      
      //delete primary child contact from the SR
      
      
      
    }catch(Exception e){
      println("Headers:"+conn.responseHTTPHeaders)
      println("Status:"+conn.statusCode)
      println("Error:"+e)
      def msg='Error cancelling Action Plan:'+e
      throw new oracle.jbo.ValidationException(msg)
      
      return
    }
      
    def msgSuccess='Action Plan has been cancelled. Please close SR record.'
      
    throw new oracle.jbo.ValidationException(msgSuccess)
    
  8. Click Save and Close.