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
Guru Vemuru 1Guru Vemuru 1 

How to Concatenate two strings based on Cirtain condition?

Hi everyone,
         
I have two objects Expense and Travel request and both are related by a lookup.
1.Travel Request has two fields like Travel_Purpose__c(Text Field) and Client_Visit__c(Look Up With Account).
2.Expense has two fields like Travel_Request__c(Look Up with Travel Request ) and Claim_Purpose__c(Text)
3.Now when i select Travel_Request__c then Claim_Purpose__c automatically in the same Editable page update like
              If(Travel_Request__c != Null)     
                    {
                         (Claim_Purpose__c= Travel_Purpose__c+Clent_Visit__c)
                     }

 
Prosenjit Sarkar 7Prosenjit Sarkar 7
Hi Guru, 

Please try with this code snippet, 
 
If(Expense_API_Name__c.Travel_Request__c != Null)     
                    {
                         Expense_API_Name__c.Claim_Purpose__c = '' + Travel_Request_API_name__c.Travel_Purpose__c + Travel_Request_API_name__c.Client_Visit__c;
                     }

Thanks and Regards,
Prosenjit Sarkar​
Guru Vemuru 1Guru Vemuru 1
Hi Sankar,
               I implement same, but still it is not working. Can you please check

public with sharing class DataPopulate {
 public Travel_Request__c trq {get; set; }

 private ApexPages.StandardController stdCtrl;

 public DataPopulate(ApexPages.StandardController std)
{
  stdCtrl = std;
 }

 public void doInsert() {
  Expense__c exp = (Expense__c) stdCtrl.getRecord();
  if (exp.Travel_Request__c == null) {
   return;
  } else {
   trq = [select Name , Proposed_Client_to_Visit__c, Status__c from Travel_Request__c where Id = : exp.Travel_Request__c LIMIT 1];
    System.debug('The record fetched '+trq);
   exp.Claim_Purpose__c= trq.Name +''+ trq.Proposed_Client_to_Visit__c;
   exp.Comments__c=trq.Status__c;
   upsert exp;
  System.debug('The record insert '+exp);
  }
 }
}