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
SFDC n12SFDC n12 

how to add a text content +value in trigger

Hi,

I have a trigger which copies all the values of fields from one object to another,

I want to add some text value to specific field followed by the value

Trigger Leadprocess on Lead_Object__c(after insert,after update)
{
     List<Lead> sub=new List<Lead>();
     for(Lead_Object__c v : Trigger.new)
     {
         
                   Lead  s = new Lead();
                  // s.RecordType.name =v.Record_Type__c;
                   s.FirstName=v.First_Name__c; 
                   s.LastName =v.Last_Name__c;
                   s.Account_Type__c = v.Account_Type__c;
                   s.Units_In_Inventory__c = v.Units_In_Inventory__c;
                   s.Company = v.company__c;
                   s.PostalCode = v.Billing_Zip__c; 
                   s.AnnualRevenue =v.Annual__c;
                   s.Salutation  = v.Salutation__c;
                   s.LeadSource =v.Record_Type__c;
                   s.Status =v.Leadstatus__c;
                   s.Additional_Information__c =v.ZID__c;  
                   sub.add(s);
           
           
            insert sub;
     }
}


Something like this,


s.Additional_Information__c ="The entered value is "+ v.ZID__c;

Please help me to know how to do this

Thanks in Advance
 

Best Answer chosen by SFDC n12
Vishant ShahVishant Shah
HI Bharath,

What you've done there is correct, except you have put in double quotes, you need to use single quotes for text expressions in SFDC

if the value is not of type string, cast it to a string using string.valueof(YOURFIELDHERE);

Hope this helps

Vish

All Answers

Vishant ShahVishant Shah
HI Bharath,

What you've done there is correct, except you have put in double quotes, you need to use single quotes for text expressions in SFDC

if the value is not of type string, cast it to a string using string.valueof(YOURFIELDHERE);

Hope this helps

Vish
This was selected as the best answer
Vishant ShahVishant Shah
You also need to keep in mind the field length for the fields you are setting in the Lead object

Vish
SFDC n12SFDC n12
Thanks dude it worked  :-)