Skip to content

Instantly share code, notes, and snippets.

@jnerius
Created May 20, 2016 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnerius/e7ff64b842c3c12065503552888ef523 to your computer and use it in GitHub Desktop.
Save jnerius/e7ff64b842c3c12065503552888ef523 to your computer and use it in GitHub Desktop.
//Define some vars
var doc = conversation.document;
var table = doc.getTableName();
var sysId = doc.getUniqueValue();
var display = doc.getDisplayValue();
var docLink = "<" + gs.getProperty('glide.servlet.uri') + "/" + doc.getLink() + "|" + display + ">";
//Create the messages for Connect and Slack
var connectMessage = "(via " + gs.getUserDisplayName() + ") " + text;
var slackMessage = "(via " + gs.getUserDisplayName() + ") " + docLink + ": " + text;
//If message sent successfully, then write to Connect
var sentMessage = sendSlackMessage(slackMessage);
if(sentMessage == '200'){
var c = new global.ConnectActionUtil(table, sysId);
c.sendMessage(connectMessage, 'SlackBot');
}
//Method for sending message to Slack
function sendSlackMessage(message) {
var channel = '#general';
var botName = 'ConnectBot';
var scu = new x_cc16_oauth.SlackConnectUtil();
var response = scu.sendMessage(channel, botName, message);
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
return httpStatus;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment