+ Start a Discussion
RajevlsRajevls 

Null Value- when trying to copy one text field to another

if(System.Trigger.oldMap.get(T.Id).Task_Comments__c != T.Task_Comments__c ){
               
               T.Description += '\n'+ ' ' +Uname +':'+' '+ ModDate +':'+' '+ T.Task_Comments__c + '\n' + '\n';
                              
               }
If Task_Comments__c is Null  then Description is null

 

On 1st enrty  

-------------------
null
Rajeev: 2013-01-23 15:57:35: Test
--------------

Second entry

---------
null
Rajeev : 2013-01-23 15:57:35: Test
Rajeev : 2013-01-23 15:57:51: Test Data
----------

 

how can i remove this null from from getting populated?

Best Answer chosen by Admin (Salesforce Developers) 
Naidu PothiniNaidu Pothini
if(System.Trigger.oldMap.get(T.Id).Task_Comments__c != T.Task_Comments__c && T.Task_Comments__c <> null)
{
	if(T.Description <> null)
	{
		T.Description += '\n'+ ' ' +Uname +':'+' '+ ModDate +':'+' '+ T.Task_Comments__c + '\n' + '\n';
	}
	else
	{
		T.Description = Uname +':'+' '+ ModDate +':'+' '+ T.Task_Comments__c + '\n' + '\n';
	}
}

 

 Did you try adding a condition to check for null value??

All Answers

Naidu PothiniNaidu Pothini
if(System.Trigger.oldMap.get(T.Id).Task_Comments__c != T.Task_Comments__c && T.Task_Comments__c <> null)
{
	if(T.Description <> null)
	{
		T.Description += '\n'+ ' ' +Uname +':'+' '+ ModDate +':'+' '+ T.Task_Comments__c + '\n' + '\n';
	}
	else
	{
		T.Description = Uname +':'+' '+ ModDate +':'+' '+ T.Task_Comments__c + '\n' + '\n';
	}
}

 

 Did you try adding a condition to check for null value??

This was selected as the best answer
RajevlsRajevls

Thanks Naidu ..

 

I was checking the Null value outside the loop thats why getting the error . Thanks for the help.