AnsweredAssumed Answered

PHP not being executed from ajax on custom button

Question asked by Chris Bowen on Jan 19, 2017
Latest reply on Jan 20, 2017 by Chris Bowen

Hey all, I'm having some trouble with an ajax call on a custom button. The custom button is on the cases list view, and there is one for each case in the list. When clicked, this button should execute an ajax call to a custom endpoint, update the assigned_user_id to the currently logged in user, and redirect to the case which the button is associated with. 


Currently, I'm hitting the endpoint, and can log the ID of the case being sent over via the ajax call, but can't get the call to update the case assigned user.


Here is the ajax call: 

function take_ticket(url, id) {
          url: '/custom/modules/Cases/assign_ticket.php',
          contentType: 'JSON',
          data: {
               'id': id
          success: function(response){
               //window.location = url;
          error: function(response) {
     return false;


And here is the custom endpoint I created (note I'm hard-coding the user ID for testing): 

if ($_GET['id']) {
    $test = $_GET['id'];

function updateUser($test) {
    $case = new aCase();
    $case->assigned_user_id = 'a5c636c4-9712-d84a-7e81-585becf9dc52'


If I remove all of the case creation/update logic and just echo $test, I get the response back that I would expect. However, with the update logic in place, my response is empty even if I simply echo $test, and the case does not get updated.