• Sergii Grushai 25
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 9
    Replies
Hi Mates,

I need a help on integrating salesforce to jira and viceversa without any plugin/addon/third party tools in developer edition

i was trying to push case from salesforce to jira as issue, and it is done using Callout working fine
But also need to push issue from jira to salesforce as case for this i created a webhook and created apex rest api class in salesforce and made that class as public from site, see below class

@RestResource(urlMapping='/JiraToSFRestTest/*')
global class JiraTOSFRestTestController {
  @HttpPost
    global static String doPost(String issueId,String issueKey, String projectId, String projectKey) {
        Case CaseObj = new Case();
        CaseObj.Status = 'Working';
        CaseObj.Origin = 'Web';
        CaseObj.Subject = issueId+'->'+issueKey;
        CaseObj.Description = projectId+'->'+projectKey;
        insert CaseObj;
        return CaseObj.Id;
    }
}


webhook url look like this
https://SaleforceSiteURL/services/apexrest/JiraToSFRestTest?issueId=${issue.id}&issueKey=${issue.key}&projectId=${project.id}&projectKey=${project.key}

I am executing this rest class from workbench then it is working fine but how to call this rest api class directly without login into salesforce from jira webhook

Don't know how to impletement can any one help on this with step by step preocedure please

Awaiting your responce
I am trying to automate a report by scheduling the report to run at a date/time and emailing the results to mail group.

How do I send report results to mail group?

Apparently via the standard Salesfore functionality that is not possible that is why I need to know is there any other way and workaround to be able to send a scheduled report to mail group?

How about running the report in Apex and generating and sending emails in code.

Please advise and share an appropriate example.
I am trying to alter the code provided by Service Rocket. We need the trigger to fire when the approval process tied to Custom_Dev__C is approved. I have little experience with writing Apex or any code. I understand that it’s creating the Jira issue when a new case is created.
 
  1. Compare in Trigger and have this in IF Condition whether [Approved__c == True]
    1. Approved__c is a checkbox that is subject to a field update after going through the approval process.
Could someone please help me make the necessary changes to get this working? Or explain where to insert the code to make it work.
trigger CreateIssue on Custom_Dev__C (before insert) {
// Check whether current user is not JIRA agent so that we don't create an infinite loop.
  if (JIRA.currentUserIsNotJiraAgent()) {
    for (Custom_Dev__C c : Trigger.new) {
      // Define parameters to be used in calling Apex Class
      String objectType =  ‘Custom_Dev__C’; // Please change this according to the object type
      String objectId = c.id;
      String projectKey = 'CustomDev'; //Please change this according to the JIRA project key
      String issueType = '10';   //Please change this according to the JIRA issue type ID
      // Calls the actual callout to create the JIRA issue.
      JIRAConnectorWebserviceCalloutCreate.createIssue(JIRA.baseUrl, JIRA.systemId, objectType, objectId, projectKey, issueType);
    }
  }
   
}
 
 
Hi,

How to integrate JIRA With salesforce?
whenever changing the status to new automatically ticket will be created in jira? how to approach it?
 When ever a case has ben created it should directly create an issue  in Jira(wrote a Trigger on case object whenever a case is identified it will fire by applying some condition) now its turn to attach a file or attachment into Jira from Salesforce, myself strucked ova here.



public SalesforcetoJira(){}
//Change values in this class according to you JIRA/Salesforce coordinates
public String baseUrl = '';   // Base URL of your JIRA instance
public String username = ''; // JIRA username
public String password = ''; // JIRA password // Constructs Basic Http Authentication header from provided credentials
public String authHeader(){ Blob headerValue = Blob.valueOf(username+':'+password); return 'Basic ' + EncodingUtil.base64Encode(headerValue);
}
public SalesforcetoJira(JiraUrl,String objectType,String projectKey,String issueType,string summary,string description)
{
HttpRequest req = new HttpRequest();
Http http = new Http();
req.setMethod('GET');
//Set HTTPRequest header properties
req.setHeader('Accept', 'application/json');
req.setHeader('Content-Type','application/json');
Blob headerValue = Blob.valueOf(username+':'+password);
req.setHeader('Authorization','Basic '+ EncodingUtil.base64Encode(headerValue));
req.setEndpoint(baseUrl);
String CreateIssueJsonJIra= '{"fields": {"project":{"key": " "},"summary":" ","description":" " ,"issuetype":{"name": "Bug"}}} ';
String JSONData = JSON.serializePretty(CreateIssueJsonJIra); r
eq.setBody(CreateIssueJsonJIra);
system.debug('after response....'+CreateIssueJsonJIra);
try{
//Execute web service call here
HTTPResponse res = http.send(req);
String ResponseJsonString = res.getBody();
map<string,string> attachment= (map<string,string>)JSON.deserializeUntyped(ResponseJsonStringJIra);
system.debug('after response...'+attachment);
system.debug('after response...'+attachment.get('id'));
System.debug('ResponseJsonStringJIra'+ResponseJsonStringJIra);
JSONParser parser = JSON.createParser(ResponseJsonStringJIra);
}
}
catch(System.CalloutException e)
{
System.debug('Callout error: '+ e);
}
}


I appreciate any help.

 
I can't seem to update my trigger so that it only creates a ticket in Jira (webservice connector) when the case status equals "Escalated". Can someone help?

trigger SynchronizeWithJIRAIssue on Case (after insert) {
    system.debug('trigger!');
    //Identify profile name to be blocked from executing this trigger
    String JIRAAgentProfileName = 'JIRA Agent2';
    List<Profile> p = [SELECT Id FROM Profile WHERE Name=:JIRAAgentProfileName];

    //Check if specified Profile Name exist or not
    if(!p.isEmpty())
    {
        //Check if current user's profile is catergorized in the blocked profile
        if(UserInfo.getProfileId()!= String.valueOf(p[0].id))
        {
            for (Case c : Trigger.new) {
                    system.debug('inside case ' + c.CaseNumber);
                    //Define parameters to be used in calling Apex Class
                    String jiraURL = 'http://xxxxxxx';
                    String systemId = '2';
                    String objectType ='Case';
                    String objectId = c.id;
                    String projectKey = 'xxx';
                    String issueType = 'xx';
               
                    System.debug('\n\n status is escalated');
                    //Execute the trigger
                    JIRAConnectorWebserviceCallout.CreateIssue(jiraURL, systemId ,objectType,objectId,projectKey,issueType);
             }
        }
    }
}

Hi ,

 

Can anyone make recommendations of the tools available to connect Salesforce and JIRA?( This is to integrate Salesforce.com cases and JIRA issues)

 

Thanks in advance!!!