Configure an Object Function for Cancel Action Plan
You must configure an object function for canceling action plan.
Following are the steps:
-
Sign in to Oracle CX Sales using Administrator role.
-
Navigate to Application Composer.
-
Go to Service Request > Server Scripts.
-
Go to Object Functions tab.
-
Click New icon to add a new object function.
-
Provide the function name as CancelProcess.
-
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)
-
Click Save and Close.