You need to sign in to do that
Don't have an account?
TheLearner
Concating the text while displaying the record
Hi Experts,
My requirement is that, i enter the value in the Text box field called NCT09a Traffic Management(NCT09a_Traffic_Management__c )= 'two way lights to be used'. Then i have field called Condition Text(Condition_Text__c ) in that box value has to display like this 'NCT09a two way traffic lights to be used'. This is my trigger ,like this there are 20 fields are there i will enter the in those fields and values has to display in that field ,but i posted only one field , could anyone help me please.
trigger Update_Condition_Text on SW_Condition__c (before insert, before update)
{
String newConditionType='';
for(SW_Condition__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT09a_Traffic_Management__c !='' && swCon.NCT09a_Traffic_Management__c != null)
newConditionType = newConditionType + ', NCT09a Traffic Management : '+swCon.NCT09a_Traffic_Management__c ;
}
if(trigger.isUpdate)
{
if((swCon.NCT09a_Traffic_Management__c !=Trigger.oldMap.get(swCon.ID).NCT09a_Traffic_Management__c) && swCon.NCT09a_Traffic_Management__c != null && swCon.NCT09a_Traffic_Management__c !='')
newConditionType = newConditionType + ', NCT09a Traffic Management: '+swCon.NCT09a_Traffic_Management__c;
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
My requirement is that, i enter the value in the Text box field called NCT09a Traffic Management(NCT09a_Traffic_Management__c )= 'two way lights to be used'. Then i have field called Condition Text(Condition_Text__c ) in that box value has to display like this 'NCT09a two way traffic lights to be used'. This is my trigger ,like this there are 20 fields are there i will enter the in those fields and values has to display in that field ,but i posted only one field , could anyone help me please.
trigger Update_Condition_Text on SW_Condition__c (before insert, before update)
{
String newConditionType='';
for(SW_Condition__c swCon:trigger.new)
{
if(swCon.Condition_Text__c != null && swCon.Condition_Text__c != '')
newConditionType = swCon.Condition_Text__c;
if(trigger.isInsert)
{
if(swCon.NCT09a_Traffic_Management__c !='' && swCon.NCT09a_Traffic_Management__c != null)
newConditionType = newConditionType + ', NCT09a Traffic Management : '+swCon.NCT09a_Traffic_Management__c ;
}
if(trigger.isUpdate)
{
if((swCon.NCT09a_Traffic_Management__c !=Trigger.oldMap.get(swCon.ID).NCT09a_Traffic_Management__c) && swCon.NCT09a_Traffic_Management__c != null && swCon.NCT09a_Traffic_Management__c !='')
newConditionType = newConditionType + ', NCT09a Traffic Management: '+swCon.NCT09a_Traffic_Management__c;
}
if(newConditionType != null && newConditionType != '')
{
newConditionType = newConditionType.removeStart(', ');
if(newConditionType.length()>500)
{
swCon.addError('Edit text in the fields in the section NCT Details to make it 500 or less so record can save');
}
else
swCon.Condition_Text__c = newConditionType;
}
}
}
NOTE: This code has not been tested and may contain typographical or logical errors.
This makes the whole trigger a lot cleaner and more scalable. Since we are using a list on line 1 to name your fields you can control the order in which everything is concatenated.
Alternately you could probably do this in a regular formula field
Thanks for the reply but is alreay existing trigger with lot of fields so , i need to do amendment in that, so its not possible to me change the entire code in the tirgger just i gave you example of one field with requirement. so could you please make an amendement in my code only.