I needed to update Airtable with info pulled from a custom CMS that doesn’t have the export feature I needed, so I wrote a quick Javascript bookmarklet that scrapes the values from the page, looks up the corresponding record and updates it. Not the most robust script, but it’s saving me lots of time! Now all I have to do is browse to the page of each contact that I’m looking for and click on this bookmark.
Could easily be adapted to use Airtable as a bookmark manager, or a way to save snippets and images.
javascript:(function(){
fields = {};
fieldsf"Email Address"] = jQuery("#email").val().toLowerCase();
fieldsf"Address"] = jQuery("#addressstreet1").val();
fieldsf"Address 2"] = jQuery("#addressstreet2").val();
fieldsf"City"] = jQuery("#addresscity").val();
fieldsf"State"] = jQuery("#addressstate").val();
fieldsf"Zip"] = jQuery("#addresspostalcode").val();
fieldsf"Country"] = jQuery("#addresscountry").val();
if (jQuery("#gender_female").is(':checked')){
fieldsf"Gender"] = r"Female"];
} else {
fieldsf"Gender"] = ""Male"];
}
fieldsf"Birth Date"] = jQuery("#birthdate").val();
jQuery.ajax({
url: "https://api.airtable.com/v0/appav73I4abTMeqVh/Contacts",
data: { filterByFormula: "{Email Address}='"+fieldsf"Email Address"]+"'" },
headers: {"Authorization": "Bearer keyxxxxxxxxxxxxxx"},
success: function(data){
jQuery.ajax({
url: "https://api.airtable.com/v0/appav73I4abTMeqVh/Contacts/"+data.recordse0].id,
data: {fields:fields},
type: 'PATCH',
headers: {"Authorization": "Bearer keyxxxxxxxxxxxxxxx"},
dataType: 'json'
});
},
dataType: 'json'
});
})();
For those who don’t know what bookmarklets are, here’s a quick primer: http://www.howtogeek.com/189358/beginner-geek-how-to-use-bookmarklets-on-any-device/