Use jQuery to add a connection to a field




  • Avatar

    Hi Mauricio,

    Knack is expecting an Object for the email field -- take a look here:

  • Avatar
    Mauricio González

    Hello Nicolas! 

    Thank you. You saved me tons of extra time.

  • Avatar
    Mauricio González

    One extra step, which I will ask in another topic, is how to use the logged in user to add the connection to his profile. 

    For anyone wanting to add a user with values using ajax, the basic code is this:

    //execute this when user clicks the button
    	$('.button').click(function(event) {
    	// use the following data.
    	var data = {
    		field_37 : { 
    			'email' : '',	//new user email to be inserted in field 37
    			'label' : 'example'
    		field_41 : [55a1b550b2847881712431fe] //this is the id of the record you want to add to the new user inside of connection field_41
    	// insert the record
    	// this uses the PAGE API access to use an existing form to insert the record.
    	// replace XXX with your application ID
    	url: "",
    	type: "POST",
    	headers: {"X-Knack-Application-Id": "xxx", "X-Knack-REST-API-Key": "xxx"},
    	data: data,
    	success: function(response) { 
    	alert('Record Added!');


Please sign in to leave a comment.