ServiceNow and LeanKit integration - c-534/templates GitHub Wiki
In this example I'll show you how to create a simple integration between ServiceNow and LeanKit using c-534.io platform.
This integration will create one LeanKit card when a new Incident will be created in ServiceNow.
In order to create this integration on your c-534.io account you'll need to create one Microservice in c-534.io. If you want to know what a Microservice is please go ahead and read about it on our wiki page!
What you'll need to proceed:
- c-534.io account (you can sign up for a free trial)
- ServiceNow account. (ServiceNow does not provide public sandboxes for unregistered users anymore. )
- LeanKit account (you can sign up for a free trial)
Let's start!
From LeanKit you will need to get your chosen Board Id and Lane Id where you want new cards to be created by the integration.
Here's how to do it:
- To get your Board Id just open your LeanKit board (where you want new cards to be created) in browser. You should see a similar url in your browsers' address bar:
https://{accountname}.leankit.com/Boards/View/{boardId}#workflow-view
Copy the {boardId} part e.g. into the text editor, you will need this later.
- You will also need Lane Id from your LeanKit board and a Card Type Id. To get those please use this url:
Now you have everything what's needed from LeanKit.
To get started with this integration you will need to create one Microservice in c-534.io.
Here are the neccessary steps to do that:
- Import a ready Microservice code from our GitHub repository to your c-534.io account just by clicking this link. This Microservice task will be to create new cards in LeanKit when new Incidents would be created in ServiceNow. The keys "board_id" and "lane_id" you obtained during the LeanKit setup. Fill in those plus your LeanKit user name and password like in the green box below:
.
- Click "Save".
- Now go to "Transformation" tab and fill in your desired Card Type Id from LeanKit you obtained during "LeanKit setup". This is the card type which will be created in LeanKit by the integration.
- After clicking the "Save" button the url in your browsers' bar will be updated with url of newly created Microservice. You will need the last part of this url (it's called "urlsafe"), e.g.:
https://app.c534.io/microservice/config/YOU_WILL_NEED_THIS_PART
Copy your urlsafe for later use. It will be needed during ServiceNow setup.
Now you are all set in c-534.io!
In ServiceNow you will need to create one Business Rule and one REST message definition. So let's get started!
- Add a new Business Rule in ServiceNow. It's like defining an action in response to new Incident created in ServiceNow.
- Setup new Business Rule (fill in according to green boxes below):
- Setup "Advanced" properties of Business Rule by pasting this JavaScript code:
(function onAfter() {
try {
var r = new sn_ws.RESTMessageV2();
r.setHttpMethod('post');
r.setEndpoint('https://prod-k534-lit534.appspot.com/rest-json/URLSAFE_OF_YOUR_MICROSERVICE');
var incident = {
"number": String(current.number),
"short_description": String(current.short_description)
};
var body = JSON.stringify(incident);
r.setRequestBody(body);
var response = r.execute();
var responseStatus = response.getStatusCode();
var responseContentType = response.getHeader('Content-Type');
var rResponseBody = response.getBody();
} catch (ex) {
var message = ex.getMessage();
}
})();
and replacing "URLSAFE_OF_YOUR_MICROSERVICE" in this line:
r.setEndpoint('https://prod-k534-lit534.appspot.com/rest-json/URLSAFE_OF_YOUR_MICROSERVICE');
with Microservice urlsafe you copied earlier in this tutorial.
- Click "Submit" to save newly created Business Rule.
Now you have everything configured in ServiceNow!
Now you can create a new Incident in ServiceNow, in a matter of couple of seconds you should see a new card created in LeanKit. If something went wrong don't hesitate and contact us. We will be glad to give you a hand!