Created
January 7, 2016 20:48
-
-
Save lmarkus/2da64d37235c3c79b46e to your computer and use it in GitHub Desktop.
How to import a subset of a large number of users into slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var emailMatcher = /^.*\((.*)\)/; // name followed by enclosed email: akjshdkajshd (a@b.com) | |
var SKIP='0', UNSELECTED='-', INVITE='invite'; | |
//Pick all unmapped user entries | |
var unmapped = $('#target_2 select') | |
.filter(function () { | |
return $(this).find('option:selected[value="'+UNSELECTED+'"]').length > 0; | |
}); | |
//Set the default to "Skip" | |
unmapped.val(SKIP); | |
//Get the parent containers so we can match against the excel export | |
var parents = unmapped.closest('tr'); | |
var incoming = {"email1@abc.com":true,"email2@abc.com":true,"email3@abc.com":true}; | |
parents.each(function () { | |
var tr = $(this); | |
//pick email address from container (first child td): | |
var text = $(tr.children('td')[0]).html(); | |
var email = emailMatcher.exec(text)[1]; | |
if (incoming[email]) { | |
tr.find('select').val(INVITE); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment