
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dec 08, 2016 04:17 PM
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 = {};
fields["Email Address"] = jQuery("#email").val().toLowerCase();
fields["Address"] = jQuery("#addressstreet1").val();
fields["Address 2"] = jQuery("#addressstreet2").val();
fields["City"] = jQuery("#addresscity").val();
fields["State"] = jQuery("#addressstate").val();
fields["Zip"] = jQuery("#addresspostalcode").val();
fields["Country"] = jQuery("#addresscountry").val();
if (jQuery("#gender_female").is(':checked')){
fields["Gender"] = ["Female"];
} else {
fields["Gender"] = ["Male"];
}
fields["Birth Date"] = jQuery("#birthdate").val();
jQuery.ajax({
url: "https://api.airtable.com/v0/appav73I4abTMeqVh/Contacts",
data: { filterByFormula: "{Email Address}='"+fields["Email Address"]+"'" },
headers: {"Authorization": "Bearer keyxxxxxxxxxxxxxx"},
success: function(data){
jQuery.ajax({
url: "https://api.airtable.com/v0/appav73I4abTMeqVh/Contacts/"+data.records[0].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/

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 15, 2019 08:49 AM
Could you talk more detail, teach me how to change the code to use ?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 17, 2019 09:26 AM
This is a little easier and visual:
