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
Kiran MarketingKiran Marketing 

Trigger to Create Bug Record in Agile Accelerator when Case is created in Call Center App

Here i have hard coded few things as my initial requirement i just wanted to create a Work Record (Bug Type) in Agile Accelerator when a Case is created. I am able to do so with the below code however not able to attach case and bug. Please find below class code and method.Any help would be highly appreciated.
public class CaseTriggerHelperClass {
    public static void isAfterInsert(Map<Id,case> casemap)
      {
       Id RecordTypeId1 = '01228000000YbH3';
   
    for(Id I : casemap.keyset()){              
         agf__ADM_Work__c aw = new agf__ADM_Work__c();         
         aw.RecordTypeId = RecordTypeId1;
         aw.agf__Subject__c = casemap.get(I).Subject;
         aw.agf__Details_and_Steps_to_Reproduce__c = casemap.get(I).Description;
         aw.agf__Product_Tag__c = 'a0f28000000DAywAAG';
         aw.agf__Found_in_Build__c = 'a0E28000001hCTk';
         aw.agf__Impact__c = 'a0X28000000Hcjf';
         aw.agf__Frequency__c = 'a0T28000000LpJj';
         aw.agf__Priority__c = casemap.get(I).Priority;
         aw.agf__Type__c = '00N28000003qlBQ';
        insert aw;
        
      }
          
   }

}
trigger Link2Agile1 on Case (before Insert, after insert, before update) {

      if(trigger.isAfter && Trigger.isinsert)
      {
              CaseTriggerHelperClass.isAfterInsert(trigger.newmap);
      }
Where in Agile Accelerator It Should Show

 
Best Answer chosen by Kiran Marketing
Kiran MarketingKiran Marketing
Thanks i got this one resolved.

All Answers

Jim RaeJim Rae
Is the case getting inserted or not?  One suggestion, I wouldn't include your insert DML inside the for loop, that is a bad practice. This would be better.
public class CaseTriggerHelperClass {
    public static void isAfterInsert(Map<Id,case> casemap)
      {
       Id RecordTypeId1 = '01228000000YbH3';
       List<Case> newCase = New List<Case>();
   
    for(Id I : casemap.keyset()){              
         agf__ADM_Work__c aw = new agf__ADM_Work__c();         
         aw.RecordTypeId = RecordTypeId1;
         aw.agf__Subject__c = casemap.get(I).Subject;
         aw.agf__Details_and_Steps_to_Reproduce__c = casemap.get(I).Description;
         aw.agf__Product_Tag__c = 'a0f28000000DAywAAG';
         aw.agf__Found_in_Build__c = 'a0E28000001hCTk';
         aw.agf__Impact__c = 'a0X28000000Hcjf';
         aw.agf__Frequency__c = 'a0T28000000LpJj';
         aw.agf__Priority__c = casemap.get(I).Priority;
         aw.agf__Type__c = '00N28000003qlBQ';
        newCase.add(aw);
        
      }
       insert newCase;
   }

}

 
Kiran MarketingKiran Marketing
Thanks i got this one resolved.
This was selected as the best answer
Eesha HuriaEesha Huria

Hi there.

I have enabled web2case in my test environment, which inserts a case when a request is made on the website. However I need to create "Case Trigger" to create a story in Agile Accelerator. I am new to salesforce and unsure how I should proceed.

 

Any help in the right direction would be appreciated.