• HAZLITT VASUDEVAN
  • NEWBIE
  • 73 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 7
    Replies
String a = 'Hello. \n Welcome to salesforce, \n Name \n Asian Paints \n WO Number \n 12345678 \n Account Id \n 1547586597';
        List<String> lst = new List<String>();
        lst=a.split('\n');
        System.debug(lst);

output I got in a same line with a comma.
public class checktest 
{
public static void force()
   {   
        Work_Order__c work = new Work_Order__c();
        String s, s1, s2, s3='';
        String a = 'Hello. \n Welcome to salesforce, \n Name \n Asian Paints \n WO Number \n 12345678 \n Account Id \n 1547586597';
        List<String> lst = a.split('\n');
        for(integer i=0;i<lst.size();i++)
        {   
            s=lst.get(i);
            if(s.contains('Hello. \n Welcome to salesforce, \n Name \n Asian Paints \n WO Number \n 12345678 \n Account Id \n 1547586597'))
            {
                work.Email_Body__c=lst.get(i);
            }
            if(s.contains('Asian Paints'))
            { 
                i = i+3;
                s1=lst.get(i);
                work.Name = s1;
            }
            if(s.contains('12345678'))
            { 
                i = i+5;
                s2=lst.get(i);
                work.WO_Number__c =double.valueOf(s2) ;
            }
            if(s.contains('1547586597'))
            { 
                i = i+7;
                s3= lst.get(i);
                work.Account_Id__c =double.valueOf(s3);
                                
            }
        }
               
         insert work;
        }
    }
public class sand {
public static void force()
    {
       Work_Order__c work = new Work_Order__c();
       work.Name = 'Asian Paints';
       work.WO_Number__c = 1547586597;
       work.Account_Id__c = 12345678;
       work.Email_Body__c = ' ';
       String a = work.Email_Body__c;
       String[] arr = new List<String>();
       arr.add('Hello.');
       arr.add('Welcome to salesforce,'); 
       arr.add('Name'); 
       arr.add('Asian Paints'); 
       arr.add('WO Number'); 
       arr.add('1547586597'); 
       arr.add('Account Id'); 
       arr.add('12345678');  
       for(integer i=0; i<arr.size(); i++)
       {
           System.debug(arr[i].valueOf(work.Email_Body__c));
       }
       insert work;
       System.debug(work);
    }
}
User-added imageLaptop Warranty is my custom object 


User-added imagenow this code only sends the info to the given mail but I want the content to go into a separate custom object field as email body.
String a = 'Hello. \n Welcome to salesforce, \n Name \n Asian Paints \n WO Number \n 12345678 \n Account Id \n 1547586597';
        List<String> lst = new List<String>();
        lst=a.split('\n');
        System.debug(lst);

output I got in a same line with a comma.
User-added imageLaptop Warranty is my custom object 


User-added imagenow this code only sends the info to the given mail but I want the content to go into a separate custom object field as email body.