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
Katie DeLuna 7Katie DeLuna 7 

updating trigger to create a webservice ticket based on case status

I've created the following trigger and it appears to be working - except for one detail. When a Salesforce case status is "New" (or any other status, for that matter), but the status changes to 'Escalated", I need a web service ticket to be created. We are using Jira as our ticketing system.

trigger CreateWithJIRAIssue on Case (after insert, after update) {
    //Identify profile name to be blocked from executing this trigger
    List<Profile> p = [SELECT Id FROM Profile WHERE Name=:'JIRA Agent2'];
    List<Case> casesToInsert = new List<Case>();
    List<Case> casesToUpdate = new List<Case>();
    //Check if specified Profile Name exist or not
    //Check if current user's profile is catergorized in the blocked profile
    if(!p.isEmpty() && UserInfo.getProfileId()!= p[0].id)
        for (Case c :{
            //new code to check for escalated
            // all the cases that have status as 'Escalated' is added to a list called escCases
            if(Trigger.isInsert && c.Status == 'Escalated'){
            } else if(Trigger.isUpdate
                && c.Bug_number__c != null
                && (
                    //c.Account_Owner_s_Email__c != Trigger.oldMap.get(c.Id).Account_Owner_s_Email__c ||
                    c.AccountId != Trigger.oldMap.get(c.Id).AccountId ||
                    c.Description != Trigger.oldMap.get(c.Id).Description ||
                    c.Subject != Trigger.oldMap.get(c.Id).Subject ||
                    c.Status != Trigger.oldMap.get(c.Id).Status ||
                    c.Priority != Trigger.oldMap.get(c.Id).Priority ||
                    c.OwnerId != Trigger.oldMap.get(c.Id).OwnerId

        if(casesToInsert.size()>0 || casesToUpdate.size()>0 ){
            // now iterate over the selected cases and call the web service
            for(Case c : Trigger.isInsert ? casesToInsert : casesToUpdate){
                Boolean jiraCreate = false;

                    || (Trigger.isUpdate && c.Bug_number__c != null
                    && c.Status == 'Escalated' && Trigger.oldMap.get(c.Id).Status != 'Escalated'
                    jiraCreate = True;

                //for test purposes we're setting a boolean to true
                JIRAUtil.sentToJira = True;
                //when executing the future callout
                JIRAConnectorWebserviceCallout.createOrUpdateJira(c.Id, jiraCreate);
Shashikant SharmaShashikant Sharma
Can you explain what is the error you are gettin in this.