function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vikas  malikvikas malik 

trigger to execute on case status = 'Escalated'

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) {
    //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
        //Check if current user's profile is catergorized in the blocked profile
        if(UserInfo.getProfileId()!= String.valueOf(p[0].id))
            for (Case c : {
                    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 =;
                    String projectKey = 'xxx';
                    String issueType = 'xx';
                    System.debug('\n\n status is escalated');
                    //Execute the trigger
                    JIRAConnectorWebserviceCallout.CreateIssue(jiraURL, systemId ,objectType,objectId,projectKey,issueType);
Best Answer chosen by vikas malik
Gaurav NirwalGaurav Nirwal

I do have a class created, then have it reach out to the trigger. I originally had the "escalated' validtion in there, but removed it because it's wasn't working. Here is the class/callout:

global class JIRAConnectorWebserviceCallout {
    @future (callout=true)
    WebService static void createIssue( String jiraURL, String systemId, String objectType, String objectId, String projectKey, String issueType) {

   System.debug('creating issue for ' + jiraURL);
        //Set your username and password here
        String username = 'xxxxx';
        String password = 'xxxxxxx';
        //Construct HTTP request and response
        HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        Http http = new Http();
        //Construct Authorization and Content header
        Blob headerValue = Blob.valueOf(username+':'+password);
        String authorizationHeader = 'Basic ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        //Construct Endpoint
        //String endpoint = '' + objectId +
        //    '&Project=LEV&Reporter=xxxxxxxxx&Summary=test&issueType=27';
        String endpoint = '' + objectId + '/issue/create.json';
        String data = '{"project":"LEV","issueType":"27"}';
   system.debug('url is, ' + endpoint);
        system.debug('data is, ' + data);
        //Set Method and Endpoint and Body
        try {
           //Send endpoint to JIRA
           res = http.send(req);
        } catch(System.CalloutException e) {
            System.debug('Callout error: '+ e);