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
NJDeveloper019NJDeveloper019 

String concatenation????

I am trying to figure out how to concatenate strings in SalesForce Apex code.  I do not see it anywhere in string methods and as far as I can tell, its not possible.  Am i crazy here?  Is something as simple as string concatenation not available in SalesForce?

 

Thanks

Best Answer chosen by Admin (Salesforce Developers) 
AndrewXAndrewX

As far as I know it works just the same as Java:

 

String s = 'part one of string' + 'part two of string';

All Answers

AndrewXAndrewX

As far as I know it works just the same as Java:

 

String s = 'part one of string' + 'part two of string';

This was selected as the best answer
praveen murugesanpraveen murugesan

TEXT( FLOOR(Month__c ))  & Month_s__c  || TEXT( FLOOR(Month__c ))  + Month_s__c

 

TEXT will convert the Number to String and Month_c is Number field and Months_s_c is Text field. 

 

FLOOR will roundup the value so decimal value cannot displayed.

 

Thanks,

 

SalesForce Developer.

AFSAR KHAN 7AFSAR KHAN 7
trigger AccountFieldTypeUpdate on Account (before Update)
{
    set<ID> account_Id=new set<ID>();    
    for (Account MyAccount : trigger.new)
    {
        if (MyAccount.Type != trigger.oldMap.get(MyAccount.Id).type)
        {
            account_Id.add(MyAccount.Id);
        }
    }
   
    if(account_Id.size()>0)
    {
        Opportunity op = new Opportunity();
        list<Opportunity> Opportunity_list=new list<Opportunity>([ select id, AccountId ,Description from Opportunity where AccountId IN:account_Id order by CreatedDate DESC]);
        for (Account MyAccount1 : trigger.new)
        {
            for(Opportunity opp1 : Opportunity_list)
            {
                if(op.AccountId != opp1.AccountId)
                {
                    if(opp1.Description != null && MyAccount1.id == opp1.AccountId)
                    {
                        op.AccountId = opp1.AccountId;
                        MyAccount1.Description = opp1.Description;
                    }
                }
            }
       }    
    }
}