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 

Apex Trigger connecting Jira to Salesforce

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);
            }
        }
    }
}
bob_buzzardbob_buzzard
I can't see that you have more than one variable named 'c'.   Which line is it complaining about?
bob_buzzardbob_buzzard
I've tried your trigger in my dev org - I don't have the JIRA callout code, but if I comment that out the trigger compiles fine.  Is the error definitely coming from the trigger code that you posted?