• Katie DeLuna 7
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 14
    Replies
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 : Trigger.new){
            //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'){
                casesToInsert.add(c);
            } 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
                )   
            ){
                casesToUpdate.add(c);
            }
        }

        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;

                if(Trigger.isInsert
                    || (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);
            }
        }
    }
}
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);
             }
        }
    }
}
I received this error when trying to save my trigger in the developer console

An unexpected error has occurred. 207196298-81555 (749494588) for deploymentId=1drn0000000DwsMAAS If this persists, please contact customer support.

Does anyone know what this error means? SF support would not help me with this and I'm not sure what the error means.
I'm trying to write a class and trigger that allows me to call out to a webservice - Jira. However, my url is getting a 'null' status. I realized there were spaces in the url, so I added %20 in the url. I still got the same message. I've included the debug log below:

req = System.HttpRequest[Endpoint=http://jira.zzz/rest/customware/connector/1.0/B6DB-9597-179C-LL4Y/Case/500n0000001OXcrAAG/LEV/Client%20Issue%20-%20Level%201/john%doe/test/issue/synchronize.json, Method=PUT]


08:55:20.064 (64488504)|SYSTEM_METHOD_EXIT|[32]|System.debug(ANY)
08:55:20.064 (64503763)|SYSTEM_METHOD_ENTRY|[34]|System.Http.send(ANY)
08:55:20.064 (64580655)|CALLOUT_REQUEST|[34]|System.HttpRequest[Endpoint=http://jira.zzz/rest/customware/connector/1.0/B6DB-9597-179C-LL4Y/Case/500n0000001OXcrAAG/LEV/Client%20Issue%20-%20Level%201/jiohn%doe/test/issue/synchronize.json, Method=PUT]
08:55:30.077 (10077030307)|EXCEPTION_THROWN|[34]|System.CalloutException: Read timed out
08:55:30.077 (10077113104)|SYSTEM_METHOD_EXIT|[34]|System.Http.send(ANY)
08:55:30.077 (10077198962)|SYSTEM_METHOD_ENTRY|[38]|System.HttpResponse.toString()
08:55:30.077 (10077291506)|SYSTEM_METHOD_EXIT|[38]|System.HttpResponse.toString()
08:55:30.077 (10077319303)|SYSTEM_METHOD_ENTRY|[38]|System.debug(ANY)
08:55:30.077 (10077335189)|USER_DEBUG|[38]|DEBUG|

exception caught = System.HttpResponse[Status=null, StatusCode=0]

I'm just now incorporating the Default Revenue Schedule for our Products. However, I was wondering if I could reate a workflow rule or some type of apex trigger that updates the product depending on the price book? If so, is there sample code that I could work off of to get me started? I just took an intro to apex, so i'm VERY new to apex.

Thanks!
Hello! I wrote the following trigger to try to create an Issue in JIRA when a case has a status of 'escalated'. However, it's saying that i have a duplicate variable of 'c'. Any ideas? I'm a newbie in apex!

trigger SynchronizeWithJIRAIssue on Case (after update) {
   
   //Identify the Case Type
   String CaseStatus = 'Escalated';
    List<Case> z = [SELECT Id FROM Case WHERE Status=:CaseStatus];
   
    //Identify profile name to be blocked from executing this trigger
    String JIRAAgentProfileName = 'JIRA Agent';
    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) {
                 String jiraURL = 'http://jira';
                    String systemId = 'B6DB-9597-179C-LL4Y';
                    String objectType ='Case';
                 String Status = 'Escalated';
                    String projectKey = 'LEV';
                    String issueType = 'Client Issue - Level 1';
                    String objectId = c.id;
                    //Execute the call
                    JIRAConnectorWebserviceCallout.synchronizeWithJIRAIssue(objectId);
            }
        }
    }
}
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);
             }
        }
    }
}
I received this error when trying to save my trigger in the developer console

An unexpected error has occurred. 207196298-81555 (749494588) for deploymentId=1drn0000000DwsMAAS If this persists, please contact customer support.

Does anyone know what this error means? SF support would not help me with this and I'm not sure what the error means.
I'm trying to write a class and trigger that allows me to call out to a webservice - Jira. However, my url is getting a 'null' status. I realized there were spaces in the url, so I added %20 in the url. I still got the same message. I've included the debug log below:

req = System.HttpRequest[Endpoint=http://jira.zzz/rest/customware/connector/1.0/B6DB-9597-179C-LL4Y/Case/500n0000001OXcrAAG/LEV/Client%20Issue%20-%20Level%201/john%doe/test/issue/synchronize.json, Method=PUT]


08:55:20.064 (64488504)|SYSTEM_METHOD_EXIT|[32]|System.debug(ANY)
08:55:20.064 (64503763)|SYSTEM_METHOD_ENTRY|[34]|System.Http.send(ANY)
08:55:20.064 (64580655)|CALLOUT_REQUEST|[34]|System.HttpRequest[Endpoint=http://jira.zzz/rest/customware/connector/1.0/B6DB-9597-179C-LL4Y/Case/500n0000001OXcrAAG/LEV/Client%20Issue%20-%20Level%201/jiohn%doe/test/issue/synchronize.json, Method=PUT]
08:55:30.077 (10077030307)|EXCEPTION_THROWN|[34]|System.CalloutException: Read timed out
08:55:30.077 (10077113104)|SYSTEM_METHOD_EXIT|[34]|System.Http.send(ANY)
08:55:30.077 (10077198962)|SYSTEM_METHOD_ENTRY|[38]|System.HttpResponse.toString()
08:55:30.077 (10077291506)|SYSTEM_METHOD_EXIT|[38]|System.HttpResponse.toString()
08:55:30.077 (10077319303)|SYSTEM_METHOD_ENTRY|[38]|System.debug(ANY)
08:55:30.077 (10077335189)|USER_DEBUG|[38]|DEBUG|

exception caught = System.HttpResponse[Status=null, StatusCode=0]