• Joe Mauras
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello everyone,
I have a Trigger that simply concatenates fields in an object. However if any of the fields are blank it returns NULL. I would like it to return nothing. I tried a couple things with no luck. Any help would be appreciated. Thanks. 

EXAMPLE:
 User-added image
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 + obj.REACH_RoHS_Value__c + obj.Spec_Formula_Value__c + '\n' +
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: AS-568';
        }


 
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: ';        
        }

 
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: ';        
        }