Howdy Guys and Gals,
I'm tasked with integrating our Salesforce and Jira cloud instances. I'm following this tutorial: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/quickstart_oauth.htm
For example, I want to start this by accomplishing a simple trigger for emails sent to salesforce.support@mycompany.com to send to jira as tickets.
Right now i'm setting up the Connected App in salesforce but I'm not sure what my callback url should be - I would assume something in jira with an api token but I'm not sure how i'm suppose to generate this URL.
Any help would be greatly appreciated!
Figured it out.
I don't even need to set this up on the salesforce side since I'll only be using callouts to jira.
Would have appreciated someone simply specifying callback urls as the different ways to preform certain tasks w/ examples.
Hi @Alec Jasanovsky,
Perhaps you can consider using Salesforce and Jira Cloud Connector app for the integration between Jira Cloud and Salesforce.
We have documented the full steps on how to configure the Connector in the following documentation.
Feel free to send us an email to support@servicerocket.com if you need further assistance for the installation for the Salesforce and Jira Cloud Connector.
Hi Victor,
Thanks but I'm not really interested in using a third party addon. I'd like to create this on my own.
Actually - (for anyone else using this for reference) you do need to do this on Salesforce side for the purpose of authentication on jira's side. When setting up the application links in jira, you need consumer keys and whatnot - all of which are generated from the salesforce "connected app".
Hey Alec,
I am trying to do something similar.
Sync cases from SFDC to JIRA and vice-versa.
Could you please let me know what value goes in the callback url of the connected app?
Also, how do you configure the push from JIRA to SFDC?
Any help is appreciated!
Hi Alec,
Did you complete your integration with JIRA & SFDC ? i need help.
Regards,
Prabu
whatsapp:+91 9080487629
Hi Prabu,
I did - where are you stuck?
I trying to do the code in JIRA also, for example i am trying to implement a workflow post function to push a JIRA issue to salesforce.If you have any other mechanism to push JIRA issue to salesforce also let me know.
can you give me the code for pushing the JIRA issue to salesforce ?
email: prabu.mxian@gmail.com
Hi Pradu!
Sorry for the terrible delay - I just switched jobs! (=D)
Here's my code, I'll explain under it:
global class caseEmailClass { public Opportunity m_opt { get; private set; } public List<Opportunity_Buy__c> selllineList { get; private set; } Public Boolean PBFlag{get;set;} public String recordId; public String accountName; Public User u; public String link = 'https://test.com'; public caseEmailClass(ApexPages.StandardController stdController) { final ApexPages.StandardController m_stdController; //public Slack_ChannelUserSelectController(ApexPages.StandardController stdController) recordId = System.currentPageReference().getParameters().get('ID'); m_stdController = stdController; try { m_opt = (Opportunity)m_stdController.getRecord(); m_opt = [select Id,Brand__c,Jira_Key__c,CurrencyIsoCode,Biz_Analyst__c,Opportunity_Number__c,Gross_Budget__c,Account.Name, Name from Opportunity where Id =: recordId]; selllineList = [select Id, Planned_Payable_Impressions__c from Opportunity_Buy__c where opportunity__c =: recordId]; } catch( exception e ) { ApexPages.addMessage( new ApexPages.Message(ApexPages.Severity.ERROR, 'Error of geting parent ' + e) ); return; } } public PageReference makeCallout (){ //@future(callout=true) u = [select Id, Name from User where User.Id=:m_opt.Biz_Analyst__c]; PBFlag = true; // make ticket submitted visable system.debug('test during first callout---------------' + m_opt.Biz_Analyst__c); system.debug('checking what sell lines object looks like at place 1---------------' + u.Name); HttpRequest request = new HttpRequest(); request.setMethod('POST'); String userpassStr = 'username@domain.com:XG1SkjcR7fYR1eYNlo7D72C7';//jira email + jira api token Blob userpassBlob = Blob.valueOf(userpassStr); string encodedStr = EncodingUtil.base64Encode(userpassBlob); String authorizationHeader = 'Basic ' + 'YWxlYy5qYXNhbm92c2t5QHhheGlzLmNvbTpHb2Rpc25vdGdyZWF0MSEhMQ=='; request.setHeader('Authorization', authorizationHeader); request.setHeader('Content-Type','application/json'); String endpoint = 'https://dev-envir.atlassian.net/rest/api/2/issue'; request.setBody('{"fields": {"project":{"key": "SAL"},"summary":" ' + m_opt.Name + ' ","customfield_10051":" ' + m_opt.Opportunity_Number__c + ' ","customfield_10055":" ' + u.Name + ' ","customfield_10049":" ' + m_opt.Brand__c + ' ","customfield_10063":" ' + selllineList + ' ","customfield_10048":" ' + m_opt.Account.Name + ' ","customfield_10052":" ' + m_opt.Gross_Budget__c + ' ","description": "test","issuetype": {"name": "Bug"}}}'); request.setEndPoint(endpoint); // corresponding jira key String jiraKey = ''; if (m_opt.Jira_Key__c == null){ // Send the HTTP request and get the response. HttpResponse response = new HTTP().send(request); // Parse the JSON response if (response.getStatusCode() != 201) { System.debug('The status code returned was not expected: ' + response.getStatusCode() + ' ' + response.getStatus()); } else { System.debug('------response is ' + response.getBody()); JSONParser parser = JSON.createParser(response.getBody()); while (parser.nextToken() != null) { if (parser.getCurrentName() == 'key'){ jiraKey = parser.getText(); m_opt.Jira_Key__c = jiraKey; update m_opt; } } } } else{// end of checking for already existing ticket // runs if jira key already exists, updates the ticket jiraKey = m_opt.Jira_Key__c; request.setMethod('PUT'); endpoint = 'https://dev-envir.atlassian.net/rest/api/2/issue/' + jiraKey; request.setBody('{"fields": { "summary":" ' + m_opt.Name + ' ","customfield_10064":{"value": "Yes"},"customfield_10070":{"name": "admin"},"customfield_10061":" ' + link + ' ","customfield_10060":" ' + link + ' ","customfield_10059":" ' + link + ' ","customfield_10058":" ' + link + ' ","customfield_10055":" ' + u.Name + ' ","customfield_10051":" ' + m_opt.Opportunity_Number__c + ' ","customfield_10063":" ' + selllineList + ' ","customfield_10052":" ' + m_opt.CurrencyIsoCode + m_opt.Gross_Budget__c + ' ","customfield_10049":" ' + m_opt.Brand__c + ' ","customfield_10048":" ' + m_opt.Account.Name + ' "}}'); request.setEndPoint(endpoint); HttpResponse response = new HTTP().send(request); System.debug('------------------- update ticket response-------------' + response.getBody()); } return null; } // end of method }
In order to tell whether the ticket was created already, I just created a new ticket on campaigns called Jira Key - if it was null, then it's yet to be ported to jira so it'll use the POST request call to create a new ticket.
If the Jira Key has a value, then it appends to the PUT call and updates the fields based on whatever was updated in SF.
I also used a visual force button to check and submit on click:
<apex:page standardcontroller="Opportunity" extensions="caseEmailClass"> <apex:form > <apex:pageBlock > Select the Button to submit this Opportunity into Jira at xaxistech.atlassian.net <br></br> <apex:commandButton action="{!makeCallout}" value="Submit To jira" id="btnUserSearch"/> <apex:commandButton action="null" value="Pull from Jira" id="pullJira"/> <apex:pageBlockSection id="pageBlock" rendered="{!PBFlag}"> <br> Ticket Submitted </br> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
Thank you so much Alec! by the way i started learning JIRA code also since my business wants to push the issue from JIRA to SFDC from JIRA side(or by JIRA Code)...so i'm trying to get JIRA code...
FYI, I'm communicating with another JIRA expert in this link :https://community.atlassian.com/t5/Jira-Core-questions/how-to-start-development-with-JIRA/qaq-p/1086992#M43191
Hi @Alec Jasanovsky ,
I would like to say thank you
Done with my Salesforce -- JIRA integration POC
Demo Video of MY POC: https://drive.google.com/file/d/10MsHbK9kHH-0YmI7aaEJv66YkzqdRavp/view?usp=sharing
Salesforce & JIRA Code of my POC : https://drive.google.com/file/d/1sUepNqdIEoo3n9P6yfdI-wDOYxXtb_RE/view?usp=sharing
Thank you so much for your guidance!
It looks like you're new here. Sign in or register to get started.