Need Java Script so a deleted user is also deleted from all users

Anyone done anything like this?

what would you charge to write my Java script for this?

is 'https://api.knack.com/v1/objects/object_8/records/' your All User record URL?


I've done that exact thing: When a user role record is deleted (it only removes the user role and not the actual user completely), I use ajax to get the parent record id and delete the user. You'd have to customize the code to fit your exact scenes/views/fields. But it should point you in the right direction.

/* --------------------------- DELETE ALL USER RECORD ON SUB EMP DELETION ------------------------- */

$(document).on('knack-record-delete.view_898', function(event, view, record) {

//alert('deleted a record, ID is: ' + record.id);

Knack.showSpinner();

$.ajax({

url: 'https://api.knack.com/v1/objects/object_8/records/'

, type: 'GET'

, headers: {

'X-Knack-Application-Id': 'your ID'

, 'X-Knack-REST-API-Key': 'your KEY'

}

, success: handledata

})

});

function handledata(data){

if (data.records.length > 0) {

//alert('got API Records');

var Email = data.records[0].field_76_raw.email;

console.log(Email);

// api

var api_url = 'https://api.knack.com/v1/objects/object_8/records/';

// preparing filters

var filters = [{field: 'field_76',operator: 'is',value: Email}]

// add to URL

api_url += '?filters=' + encodeURIComponent(JSON.stringify(filters));

$.ajax({

url: api_url,

type: 'GET',

headers: {'X-Knack-Application-Id': 'your ID', 'X-Knack-REST-API-Key': 'your KEY'},

success: deletedata

})

}

};

function deletedata(myrecord){

if (myrecord.records.length > 0) {

//alert('got API Record');

var recID = myrecord.records[0].id;

console.log(recID);

// api

var api_url = 'https://api.knack.com/v1/objects/object_8/records/'+ recID;

$.ajax({

url: api_url,

type: 'DELETE',

headers: {'X-Knack-Application-Id': 'your ID', 'X-Knack-REST-API-Key': 'your KEY'},

success: function(myrecord){

console.log('Deleted API record: '+ recID);

console.log (myrecord);

Knack.hideSpinner();

}

})

}

};

/* ---------------------- END DELETE ALL USER RECORD ON SUB EMP DELETION ----------------------- */