• Rishabh Goyal 18
  • NEWBIE
  • 50 Points
  • Member since 2019

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi, I am new to Apex. I have the below doubt,
trigger ClosedOpportunity on Opportunity (after update) {
    List<task> carry=New List<task>();
    for(opportunity opp:trigger.new){
    if(opp.stagename=='Closed won'){
     task t=new task(
         whatid=opp.id,
         status='Active',
         Subject='Follow Up Opp Task',
         ActivityDate=system.today()
     ) ; 
        carry.add(t);
    }
        }
    insert carry;
}
In the above, code. Its working when i am putting "Insert carry" But not working if i want to put "Insert t", As i can see both are instances created, so why do i have to create "carry" and add "t" in that. Why not i can "insert t" directly ?
 
Hello all. I'm as new as it comes to Apex. I'm on Trailhead learning about it but I could use help with the Test code to get the ball rolling. My trigger (so far) simply concatenates a bunch of fields based on another field. I would appreciate any help. Thank you.
trigger Item_Desc_Trigger on Item_Creation__c (before insert, before update){


for (Item_Creation__c obj: trigger.new){

    obj.Item_Description__c = '';
    obj.Extended_Description__c = '';

    if ( obj.Item_Description_Code__c == 'ORAS' )
        {
            obj.Item_Description__c = obj.Default_Product_Group_Value__c + '-' + obj.Subcategory_Group_Code__c + ' ' + obj.O_ring_Size_Value__c + ' ' + obj.Material_Family_Value__c + ' ' + obj.Compound_Name_Value__c;
            
            obj.Extended_Description__c = obj.Product_Group_Value__c + ' ' + obj.Subcategory_Group_Value__c + '\n' + 
                obj.Material_Family_Value__c + ' ' + obj.Durometer__c + ' ' + obj.Color__c + ', RoHS / Reach, AMS 83485' + '\n' +  // FIX THIS***
                obj.Nominal_ID_Value__c + '"ID x ' + obj.Nominal_CS_Value__c + '"CS Nom. (' + obj.ID__c + '"ID x ' + obj.CS__c + '"CS)' + '\n' +
                'Tolerances: ' + obj.Subcategory_Group_Value__c;
        }

    else if ( obj.Item_Description_Code__c == 'ORMM' )
        {
            obj.Item_Description__c = obj.Default_Product_Group_Value__c + '-' + obj.Subcategory_Group_Code__c;
            
            obj.Extended_Description__c = obj.Product_Group_Value__c + ' - ' + 'Metric' + '\n' +
                obj.Material_Family_Value__c + ' ' + obj.Durometer__c + ' ' + obj.Color__c + ', RoHS / Reach' + '\n' +  // FIX THIS***
                'Tolerances: ';        
        }

 
Hi, I am new to Apex. I have the below doubt,
trigger ClosedOpportunity on Opportunity (after update) {
    List<task> carry=New List<task>();
    for(opportunity opp:trigger.new){
    if(opp.stagename=='Closed won'){
     task t=new task(
         whatid=opp.id,
         status='Active',
         Subject='Follow Up Opp Task',
         ActivityDate=system.today()
     ) ; 
        carry.add(t);
    }
        }
    insert carry;
}
In the above, code. Its working when i am putting "Insert carry" But not working if i want to put "Insert t", As i can see both are instances created, so why do i have to create "carry" and add "t" in that. Why not i can "insert t" directly ?
 
Hello all. I'm as new as it comes to Apex. I'm on Trailhead learning about it but I could use help with the Test code to get the ball rolling. My trigger (so far) simply concatenates a bunch of fields based on another field. I would appreciate any help. Thank you.
trigger Item_Desc_Trigger on Item_Creation__c (before insert, before update){


for (Item_Creation__c obj: trigger.new){

    obj.Item_Description__c = '';
    obj.Extended_Description__c = '';

    if ( obj.Item_Description_Code__c == 'ORAS' )
        {
            obj.Item_Description__c = obj.Default_Product_Group_Value__c + '-' + obj.Subcategory_Group_Code__c + ' ' + obj.O_ring_Size_Value__c + ' ' + obj.Material_Family_Value__c + ' ' + obj.Compound_Name_Value__c;
            
            obj.Extended_Description__c = obj.Product_Group_Value__c + ' ' + obj.Subcategory_Group_Value__c + '\n' + 
                obj.Material_Family_Value__c + ' ' + obj.Durometer__c + ' ' + obj.Color__c + ', RoHS / Reach, AMS 83485' + '\n' +  // FIX THIS***
                obj.Nominal_ID_Value__c + '"ID x ' + obj.Nominal_CS_Value__c + '"CS Nom. (' + obj.ID__c + '"ID x ' + obj.CS__c + '"CS)' + '\n' +
                'Tolerances: ' + obj.Subcategory_Group_Value__c;
        }

    else if ( obj.Item_Description_Code__c == 'ORMM' )
        {
            obj.Item_Description__c = obj.Default_Product_Group_Value__c + '-' + obj.Subcategory_Group_Code__c;
            
            obj.Extended_Description__c = obj.Product_Group_Value__c + ' - ' + 'Metric' + '\n' +
                obj.Material_Family_Value__c + ' ' + obj.Durometer__c + ' ' + obj.Color__c + ', RoHS / Reach' + '\n' +  // FIX THIS***
                'Tolerances: ';        
        }