• satheesh8.k1.3890099515516848E12
  • NEWBIE
  • 115 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 30
    Questions
  • 41
    Replies
Hi All,

Please help me regarding how to map Csv column names with selected object field name.

My requirement is, After uplaod the csv file and  related object field i want to do manual mapping. same like data loader field mapping.

Please provide code or guide me.

Thanks
Satheesh  
HI All,

Please help me,

SQOLQuery = SQOLQuery+ ' from ' + SelectedObject+ ' where ' +CSVheaderFields[uniquecolumn] +' in:SetExternalid';
       
       System.debug('---------SQOLQuery--------'+SQOLQuery);
       
        // system.debug('= csvmapfield.keyset===:'+ csvmapfield.keyset());
        system.debug('=SQOLQuery===:'+SQOLQuery);
        list<account> resultedRecords=database.query(SQOLQuery);
        
   //     Map<Id, sObject> objRecordsMap = new Map<Id, sObject>();
   //     objRecordsMap.putAll( Database.query( SQOLQuery) );
   //     System.debug('++++++++++objRecordsMap+++++++'+objRecordsMap); 
        
        
    //    map<string,account> mapacc= new map<string,account>();
        map<String, Sobject> mp=new Map<String,Sobject>();
            for(account a:resultedRecords)
            {
                //mapacc.put(a.Ext_Id__c,a);
                mapacc.put(a.Ext_Id__c,a);
               // mp.put(a.Ext_Id__c,a);
            }
          System.debug('++++++++++mapacc+++++++'+mapacc);
        integer pk=1;                                                                  
        for (String s :csvmapfield.keySet())
        {  
            System.debug('++++++++++s+++++++'+s);       
           account accountaccsinglerow = mapacc.get(s);
           // System.debug('++++++++++accountaccsinglerow +++++++'+accountaccsinglerow );
            string SobjsingeleRecord= string.valueof(accountaccsinglerow );
            System.debug('------SobjsingeleRecord-------'+SobjsingeleRecord);
            String[] SobjsingeleRecord_array = SobjsingeleRecord.split(':');
            string SobjsingeleRecord_array1=SobjsingeleRecord_array[1].trim();
            SobjsingeleRecord_array1= SobjsingeleRecord_array1.substring(0,SobjsingeleRecord_array1.length()-1);
            SobjsingeleRecord_array1=SobjsingeleRecord_array1.substring(1);
            SobjsingeleRecord_array =SobjsingeleRecord_array1.split(',');
            
            list<string> cscvsingrow= csvmapfield.get(s);
            // String[] CSVsingeleRecord_array = cscvsingrow.split(',');
            // System.debug(' =CSVsingeleRecord_array ='+CSVsingeleRecord_array );
            
            for(integer i=0;i<CSVheaderFields.size();i++)
            {
                integer flag=0;
                //System.debug(' =cscvsingrow[i] ='+cscvsingrow[i] );
                string csvfiedvalue=cscvsingrow[i];
                string field=CSVheaderFields[i].trim();
                field=field+'='+cscvsingrow[i];
                field=field.replace('\n','');
                field=field.trim();
                field=field.toLowerCase();
                
                
                 System.debug('field:'+field );
                for(integer k=0;k<SobjsingeleRecord_array.size();k++)
                {
                    // System.debug('SobjsingeleRecord_array:'+SobjsingeleRecord_array[k]);
                    string pr=SobjsingeleRecord_array[k].trim().toLowerCase();
                    System.debug('pr:'+pr);
                    
                    if(field==pr){ 
                    flag=1;
                    break;
                }
                
                }
                if(flag==0)
                {
                    fieldsnotmatch.add(csvfiedvalue);
                
                }
            
            }
            
            if(fieldsnotmatch.size()>0)
            {
            
                system.debug('====fieldsnotmatch:'+fieldsnotmatch);
                string kk=string.valueof(fieldsnotmatch);
                
                system.debug('====s:'+s);
                fieldsnotmatchmap.put(s,fieldsnotmatch);
                string loops=string.valueof(fieldsnotmatch);
                Results1[pk++].add(loops);
                fieldsnotmatch= new list<String>();
            }
            else{
                Results1[pk++].add('Match/No Err Found');
            }
        }
        
        for(string a:fieldsnotmatchmap.keyset())
        {
            system.debug('key--:'+a+':value:'+fieldsnotmatchmap.get(a));
        }
        list<string> resultlst = new list<string>();
        resultlst.add('Values didn\'t match ');
        Results1[0].addall(resultlst);
        
        /*for(integer i=1;i<Results1.size();i++)
        {
        //index.add(string.valueof(i));
        Results1[i].add('Match');
        //List<string > tt=Results[i];
        // index.add(tt);
        }
        */
        // system.debug('@@@@@@@@@@'+Results1);
        return allFields;
         
    }


above code will work only for Account Object , but i wanted to do for all object ,

Please help me how to apply for all object like account.

maily focus on below code:

map<String, Sobject> mp=new Map<String,Sobject>();
            for(account a:resultedRecords)
            {
                //mapacc.put(a.Ext_Id__c,a);
                mapacc.put(a.Ext_Id__c,a);
               // mp.put(a.Ext_Id__c,a);
            }
          System.debug('++++++++++mapacc+++++++'+mapacc);
        integer pk=1;                                                                  
        for (String s :csvmapfield.keySet())
        {  
            System.debug('++++++++++s+++++++'+s);       
           account accountaccsinglerow = mapacc.get(s);
           // System.debug('++++++++++accountaccsinglerow +++++++'+accountaccsinglerow );
            string SobjsingeleRecord= string.valueof(accountaccsinglerow );
            System.debug('------SobjsingeleRecord-------'+SobjsingeleRecord);
            String[] SobjsingeleRecord_array = SobjsingeleRecord.split(':');
            string SobjsingeleRecord_array1=SobjsingeleRecord_array[1].trim();
            SobjsingeleRecord_array1= SobjsingeleRecord_array1.substring(0,SobjsingeleRecord_array1.length()-1);
            SobjsingeleRecord_array1=SobjsingeleRecord_array1.substring(1);
            SobjsingeleRecord_array =SobjsingeleRecord_array1.split(',');
            
            list<string> cscvsingrow= csvmapfield.get(s);
            // String[] CSVsingeleRecord_array = cscvsingrow.split(',');
            // System.debug(' =CSVsingeleRecord_array ='+CSVsingeleRecord_array );
            
            for(integer i=0;i<CSVheaderFields.size();i++)
            {
                integer flag=0;
                //System.debug(' =cscvsingrow[i] ='+cscvsingrow[i] );
                string csvfiedvalue=cscvsingrow[i];
                string field=CSVheaderFields[i].trim();
                field=field+'='+cscvsingrow[i];
                field=field.replace('\n','');
                field=field.trim();
                field=field.toLowerCase();
                
                
                 System.debug('field:'+field );
                for(integer k=0;k<SobjsingeleRecord_array.size();k++)
                {
                    // System.debug('SobjsingeleRecord_array:'+SobjsingeleRecord_array[k]);
                    string pr=SobjsingeleRecord_array[k].trim().toLowerCase();
                    System.debug('pr:'+pr);
                    
                    if(field==pr){ 
                    flag=1;
                    break;
                }

Thanks
Satheesh
 
Hi All,

Please find below code ,which is working for only one object like Account , but i want this process for all object ,
please help me how to do 

<apex:page controller="csvFileReaderController">
    <apex:form >  <!-- csv reader demo -->
        <apex:pageBlock >
            <apex:panelGrid columns="2" >
                  <apex:inputFile value="{!csvFileBody}"  filename="{!csvAsString}"/>
                  <apex:commandButton value="Read csv" action="{!readcsvFile}"/>
            </apex:panelGrid>
        </apex:pageBlock>
        <apex:pageBlock >
           <apex:pageblocktable value="{!sObjectList}" var="rec">
              <apex:column value="{!rec.name}" />
              <apex:column value="{!rec.AccountNumber}" />
              <apex:column value="{!rec.Accountsource}" />
              <apex:column value="{!rec.Type}" />
              <apex:column value="{!rec.Website}" />
        </apex:pageblocktable>
     </apex:pageBlock>
     
    <apex:SelectList value="{!val}" size="1">
      <apex:selectOptions value="{!Name}"></apex:selectOptions>
    </apex:SelectList>

     
   </apex:form>
</apex:page>

apex:

Public with sharing class csvFileReaderController {
public Blob csvFileBody{get;set;}
Public string csvAsString{get;set;}
Public String[] csvfilelines{get;set;}
Public String[] inputvalues{get;set;}
Public List<string> fieldList{get;set;}
Public List<account> sObjectList{get;set;}
  public csvFileReaderController(){
    csvfilelines = new String[]{};
    fieldList = New List<string>();
    sObjectList = New List<sObject>();
  }

  Public void readcsvFile(){
       csvAsString = csvFileBody.toString();
       csvfilelines = csvAsString.split('\n');
       inputvalues = new String[]{};
       for(string st:csvfilelines[0].split(','))
           fieldList.add(st);  
       
       for(Integer i=1;i<csvfilelines.size();i++){
           Account accRec = new Account() ;
           string[] csvRecordData = csvfilelines[i].split(',');
           accRec.name = csvRecordData[0] ;            
           accRec.accountnumber = csvRecordData[1];
           accRec.Type = csvRecordData[2];
           accRec.website = csvRecordData[3];
           accRec.AccountSource = csvRecordData[4];                                                                              
           sObjectList.add(accRec);  
       }
  }
  
  public String val {get;set;}
 
  public List<SelectOption> getName()
  {
    List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values(); 
    System.debug('@@@@@@@@@'+gd);    
    List<SelectOption> options = new List<SelectOption>();
    
    for(Schema.SObjectType f : gd)
    {
       options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
    }
    System.debug('$$$$$$$$$'+options);
    return options;
    
   }
}

Thanks
Satheesh
HI All,

Please help me 
My requirement is,
I have .csv exported file like account(Account.csv) in excel sheet , now i want to convert this excel file into vf page , create a one upload file option after that convert that file into columns ,
like below screen shot :
User-added image

Please help me 

Thanks
Satheesh
HI All,
I need some clarification about java script remoting and remote objects are same or different ,

please give me clarification.

Thanks
Satheesh 
Hi All,
Please help me how to do salesforce to salesforce integation using Rest API's.

I have a link: https://resources.docs.salesforce.com/sfdc/pdf/api_rest.pdf

i follow this pdf , but  api's are not working , may be my process is wrong or anything i missed . i don't know where i did mistake.

Please give me clear steps.

Thanks
Satheesh
Hi All,

is it possible to update profile from salesforce to linkedin ?

Please if it is possible give me guideness.

Thanks 
Satheesh 
Hi All,

please help me regarding ,how to post test data and how to upload the attachment from salesforce to linkedin .

please guide me , if you have any code regarding this ,please share it to me.

Thanks
Satheesh
Hi All,

Please help me,
I got the information from linkedin and display it in VF page. but i want store those information in one custom object.

how to do this one ,
please find attached screenshot, here  first page block shows I fetched linkedin information,
second page block i created two custom fields in one custom object.

here there is no relationship between custom fields and linkedin field , please help me how to make relation or how to update custom fields with linkedin information . 

User-added image
Thanks
Satheesh
Hi All,

VF Page:

<apex:page controller="DropboxController">
<apex:form>
    <apex:pageblock>
        <apex:commandbutton action="{!DropAuth}" value="Dropbox Authentication">
    </apex:commandbutton></apex:pageblock>
</apex:form>
</apex:page>

apex:-

public class DropboxController
{
    //Fetched from URL
    String code ;
    
    public DropboxController()
    {
        code = ApexPages.currentPage().getParameters().get('code') ;
        //Get the access token once we have code
        if(code != '' && code != null)
        {
            AccessToken() ;
        }
    }
    
    public PageReference DropAuth()
    {
        //Authenticating
        PageReference pg = new PageReference('https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id=vaabb5qz4jv28t5&redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage&state=Mytesting') ;
        return pg ;
    }
    
    public void AccessToken()
    {
        //Getting access token from dropbox
        String tokenuri = 'https://api.dropbox.com/1/oauth2/token?grant_type=authorization_code&code='+code+'&redirect_uri=https://c.ap1.visual.force.com/apex/DropboxPage'; 
        HttpRequest req = new HttpRequest();
        req.setEndpoint(tokenuri);
        req.setMethod('POST');
        req.setTimeout(60*1000);
          
        Blob headerValue = Blob.valueOf('vaabb5qz4jv28t5' + ':' + 'dpmmll522bep6pt');
        String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
        req.setHeader('Authorization', authorizationHeader);
        Http h = new Http();
        String resp;
        HttpResponse res = h.send(req);
        resp = res.getBody();
        
        System.debug(' You can parse the response to get the access token ::: ' + resp);
   }
}


I got the key,secrete and redirect url from dropbox , and set it in the above code
Now i got the response as a access token from debug log

Example:-
{"access_token": "fdNB-pM_uYsAAAAAAAAANrefVrISVc9rcvRdrUmHqq46W26cDanUSzgzUwIQHr_", "token_type": "bearer", "uid": "282967343"}

but i did not get user profile infomation and app details from dropbox,

Please help me i am new for integration
as well as please explain about how to pass endpoint url with example.

Thanks
Satheesh
Hi All,

Please help me regarding integration between dropbox and salesforce ,

This Below link very useful to me  :
http://forceguru.blogspot.in/2014/05/dropbox-authentication-in-salesforce.html

but i am unable to get user profile information or app information from dropbox, please help me how to get those information , 

I did connection between salesforce to dropbox , i have access token ,api key, api secrete all things ,
but i don't know how pass request and how to get response as user details .


Please help me
Thanks
Satheesh

 
Hi All,
Please help me regardind integration between Salesforce and LinkedIn

I got code from google:
<apex:page controller="LinkedInIntegrationController">
 <apex:form >
 <apex:outputLink value="{!authorizationCodeURI}">Authorize Me</apex:outputLink>
 </apex:form>
 <div>body : {!body}</div>
 <div>responseBody : <br/><br/>{!responseBody}</div>
</apex:page>



apex:
public class LinkedInIntegrationController {
 
//Pass in the endpoint to be used
 public String responseBody{get;set;}
 public String authCode{get;set;}
 public String authorizationCodeURI{get;set;}
 public String body{get;set;}
 
public LinkedInIntegrationController(){
 
 authCode = ApexPages.currentPage().getParameters().get('code');
 authorizationCodeURI = 'https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=vcsdjaaa2ell31l& state=DCEEFWF45453sdffef424&redirect_uri=https://c.ap1.visual.force.com/apex/LinkedInPage';
 HttpResponse resToken;
 if(authCode != NULL){
 
//POST Request by using the authorization code
 Http hToken = new Http();
 HttpRequest reqToken = new HttpRequest();
 reqToken.setEndpoint('https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code='+authCode+'&redirect_uri=https://c.ap1.visual.force.com/apex/LinkedInPage&client_id=vcsdjaaa2ell31l&client_secret=D88uZlvouaRSDII2u1');
 reqToken.setMethod('POST');
 resToken = hToken.send(reqToken);
 body = resToken.getBody();
 
JSONWrapper jsonWrapObj = (JSONWrapper)JSON.deserialize(body, JSONWrapper.class);
 
//GET Request by using the access token
 Http h=new Http();
 HttpRequest req = new HttpRequest();
 req.setEndpoint('https://api.linkedin.com/v1/people/~/email-address?oauth2_access_token='+jsonWrapObj.access_token);
 req.setMethod('GET');
 req.setHeader('Content-Type','application/xml');
 HttpResponse res = h.send(req);
 responseBody = res.getBody();
}
 }
 
public class JSONWrapper{
 
public Integer expires_in;
public String access_token;
 
}
}

this is working fine but I did not got profile details like : Skills ,Education etc..

If code is not good , please give me suggestions.

Please help me ,  

Thanks
Satheesh


 
Hi All

Please help me regarding Create a flow , and how to test the flow,

Please give me steps for this

Thanks
Satheesh K 
Hi All

Please help me,

How to mass unpublish article using apex api code,
(means i need to unpublish article insteded of doing manual ).

thanks
Satheesh
HI,

please help me,

I want to migrate History tracking data from One instance to Another instance,
How can i migrate this data for all standard and Custom Objects,

I tried through data loader we can export history data but i tried to insert same data into same object there is no option for select the history object. 
please guide me , which is very urgent for my project.

Thanks
Satheesh
Hi 
please any one help me write a test class for this code:
public class CaseMergeWithParent {
public String s{ get; set; } 
    public String SearchText { get; set; }
    public String operator1 { get; set; }
    public String operator2 { get; set; }
    public String operator3 { get; set; } 
    public String SearchSubject { get; set; } 
    public boolean isclosed {get;set;}
    public String SearchDesc { get; set; }  
    public transient list<Case> CasesFound { get; set;}  
    public map<string,Case> CasesMap {get;set;}
    public map<string,string> IdCaseNumberMap { get; set; }  
    public list<Case> CasesSelected { get; set; }  
    public case c {get;set;}
    public case mc {get;set;}
    public case contcase;
    public boolean onload {get;set;}
    public boolean includeAtt {get;set;}
//    public boolean includeFeed {get;set;}    // not being used because of the complexity for the time being
    public boolean includeComments {get;set;}
    public boolean includeHist {get;set;}
    public boolean includeEmails {get;set;}
    public boolean includeSolutionDetails {get;set;}
    public boolean showtable {get;set;}  
    public string notes='';    
    public CaseMergeWithParent(ApexPages.StandardController controller){        
        showtable = false;
        onload = true;
        c = new case();
        mc = new case();
        contcase = new case();
        CasesFound = new list<Case>();
        CasesSelected = new list<Case>(); 
        CasesMap = new map<string,Case>();
        IdCaseNumberMap = new map<string,string>();        
        operator1 = operator2 = operator3 = 'AND';        
        contcase = (case)controller.getRecord();
        //Force compatibiltiy mode to IE8 so page works in IE9 browsers. Official ie9 support expected Winter12 release       
        String browserType = Apexpages.currentPage().getHeaders().get('USER-AGENT');       
        if(browserType != null && browserType.contains('MSIE')){
            Apexpages.currentPage().getHeaders().put('X-UA-Compatible', 'IE=8');
        }                 
    } 
    public PageReference runSearch() {    
       // SearchText = Apexpages.currentPage().getParameters().get('str');
        onload = false;
        string tmpSearchText = '\'%'+SearchText+'%\'';
        string tmpSearchSubject = '\'%'+SearchSubject+'%\'';         
        CasesFound = new list<case>();
        CasesSelected.clear();        
        String qryString = 'select Id, CaseNumber, Subject,IsClosed, Description, Additional_details__c, Detailed_Description__c,contactid,accountid,CreatedDate  from case'+ 
                            ' WHERE ('+
                            '(RecordTypeId = \'012G00000011jKv\')'+ 
                            +' AND ('+'isClosed = ' + isclosed+')';
                          
        IF(SearchText!=''){
                        qryString = qryString+' AND ('+'CaseNumber LIKE ' + tmpSearchText+')';
        
        } 
            
        IF(SearchSubject!=''){
            
            qryString = qryString+' '+operator1+' ('+'SUBJECT LIKE ' + tmpSearchSubject+' )' ;        
        }           
        string contactid = contcase.contactid; 
        system.debug('xxxxxxxxxxxx'+contactid);    
        IF(contactid!=null){
            
            qryString = qryString+' '+operator2+' ('+'CONTACT.ID = \'' +contactid+'\')';        
        }
         
        string accountid = contcase.accountid; 
        IF(accountid!=null){
                        qryString = qryString+' '+operator3+' ('+'ACCOUNT.ID = \'' +accountid+'\')';
        
        }  
          
        qryString = qryString+') limit 1000';
        
        system.debug('xxxxxxxxxxxx'+qryString);     
        CasesFound = Database.query(qryString);
             
        return null;
    }    
    public PageReference findSelected() {
        
        CasesFound = new list<case>();
        CasesSelected.clear();
        onload = true; 
         
        string strselcaseIds = Apexpages.currentPage().getParameters().get('all');
        
        list<string> lstselcaseIds = new list<string>();
        
        if(strselcaseIds.contains(',')){
            lstselcaseIds = strselcaseIds.split(',');
        }
        else{
            lstselcaseIds.add(strselcaseIds);
        }
         
        CasesMap = new map<string,Case>([select Id, CaseNumber, Subject,IsClosed, Description, Additional_details__c, Detailed_Description__c,contactid,accountid,CreatedDate  
                              from case where id in :lstselcaseIds]);   
        showtable = true;
        return null;
    }
 
    public void do1() {
        
        s = Apexpages.currentPage().getParameters().get('masterCaseId'); 
    }
 
  
    public pagereference casemerge(){
     
        mc = CasesMap.get(s); 
        CasesMap.remove(s);        
        list<EmailMessage> emaillist = new list<EmailMessage>();  
        Attachment[] insertAttList = new Attachment[]{};
        map<string, list<CaseComment>> caseCommMap; 
        map<string, list<CaseHistory>> caseHistMap;
        map<string, list<EmailMessage>> caseEmailMap;
        map<string, list<Attachment>> caseAttchMap;
        map<string, list<solution_details__C>> caseSDs;
            
        if(includeComments){
        
            caseCommMap = new map<string,list<CaseComment>>();
            
            for(CaseComment cc: [SELECT Id, CommentBody,CreatedDate,parentId, CreatedBy.name FROM CaseComment where parentId IN :CasesMap.keySet()]){
                
                if(!caseCommMap.containsKey(cc.parentId)){
                
                    caseCommMap.put(cc.parentId, new list<CaseComment>());                   
                }
                
                caseCommMap.get(cc.parentId).add(cc);                
            }
            
        }        
        if(includeHist){ 
        
            caseHistMap = new map<string,list<CaseHistory>>();
            
            for(CaseHistory ch: [SELECT Id, CreatedBy.name, CreatedDate, Field, OldValue, NewValue, CaseId FROM CaseHistory 
                                 where CaseId IN :CasesMap.keySet()]){
                
                if(!caseHistMap.containsKey(ch.CaseId)){
                
                    caseHistMap.put(ch.CaseId, new list<CaseHistory>());
                    
                }
                
                caseHistMap.get(ch.CaseId).add(ch);               
            }
        }        
        if(includeEmails){
        
            caseEmailMap = new map<string,list<EmailMessage>>(); 
            
            for(EmailMessage e: [SELECT Id, ActivityId, 
                                 TextBody, HtmlBody, Headers, Subject, FromName, FromAddress, ToAddress, CcAddress, parentId,
                                 BccAddress, Incoming, HasAttachment, Status, MessageDate, IsDeleted, ReplyToEmailMessageId FROM EmailMessage
                                 where parentId IN :CasesMap.keySet()]) {
               
                if(!caseEmailMap.containsKey(e.parentId)){
                
                    caseEmailMap.put(e.parentId, new list<EmailMessage>());
                    
                }
                
                caseEmailMap.get(e.parentId).add(e);
                
            } 
       
        }
        
        if(includeAtt){ 
        
            caseAttchMap = new map<string,list<Attachment>>();
              
            for(Attachment a: [SELECT Id, IsDeleted, Name, IsPrivate, ContentType, BodyLength, Body, OwnerId,parentId, 
                               Description, IsPartnerShared, ConnectionReceivedId, ConnectionSentId FROM Attachment 
                               where parentId IN :CasesMap.keySet()]) {
               
                if(!caseAttchMap.containsKey(a.parentId)){
                
                    caseAttchMap.put(a.parentId, new list<Attachment>());
                    
                }
                
                caseAttchMap.get(a.parentId).add(a);
                
            }  
            
             
        }        
        for(case cs : CasesMap.values()){
              
            mc.description = nullify(mc.description) +'\r\n'+ nullify(cs.description);            
            mc.Additional_details__c = nullify(mc.Additional_details__c) +'\r\n'+ nullify(cs.Additional_details__c);    
            mc.Detailed_Description__c = nullify(mc.Detailed_Description__c) + '\r\n'+ nullify(cs.Detailed_Description__c);    
         
             
            notes='--------------------Details Of Merged Case Number # '+cs.casenumber+'--------------------';
            notes=notes+'\r\n\r\nThis case has been merged by '+userinfo.getName()+' on '+system.now();
             
            Attachment attach1= new Attachment();
            attach1.ParentId = mc.id;
            attach1.Name = 'Merged Case# '+cs.casenumber+' Data.txt';
        
        
            
            if(includeComments && caseCommMap.containsKey(cs.Id)){
                string comments ='\r\n\r\n------------- Case Comments -------------';
                 
                for(CaseComment cc: caseCommMap.get(cs.Id)) {
                     comments = comments+'\r\n'+'Comment Created By: '+cc.CreatedBy.name +' On '+cc.CreatedDate + cc.CommentBody;
                }
                notes=notes+comments;
                  
            }
            
        
            if(includeHist && caseHistMap.containsKey(cs.Id)){ 
                string history='\r\n\r\n------------- Case Field History -------------';
                integer i=1; 
                for(CaseHistory cc: caseHistMap.get(cs.Id)) {
                     history = history+'\r\n'+i+' - '+cc.CreatedBy.name +' On '+cc.CreatedDate + ' changed '+cc.field+' from '+cc.oldvalue+' to '+cc.newvalue;
                     i++;
                }
                notes=notes+history;
                 
            }
            
            attach1.Body = Blob.valueOf(notes);
            insertAttList.add(attach1);
        
            if(includeEmails && caseEmailMap.containsKey(cs.Id)){
              
            system.debug('got in to includeEmail');
                
                for(EmailMessage e: caseEmailMap.get(cs.Id)) {
                    EmailMessage eclone = e.clone(); 
                    eclone.parentid = mc.id;
                    emaillist.add(eclone);
                } 
          
                
            }
        
            if(includeAtt && caseAttchMap.containsKey(cs.Id)){ 
                
                for(Attachment a: caseAttchMap.get(cs.Id)) {
                    Attachment aclone = a.clone();
                    aclone.parentid = mc.id;
                    insertAttList.add(aclone);
                } 
            }
              
            
        }
        
              
        if(!emaillist.isEmpty())
        { 
            insert emaillist;
        }
        
        if(!insertAttList.isEmpty()){ 
            insert insertAttList;
        }
        
        update mc;
        delete CasesMap.values(); 
        return new pagereference('/'+mc.id);
    }
    
    public static string nullify(string s){
        return ((s == null) ? ' ' : s);
    } 
    
}

Thanks
Satheesh
HI All,

please any one help me

I am a new for Migration process, please how to do migration ,what is the first step to start the process , before going to first step anything i need to understand ,  please help me and share any documents or pdf

Thanks
Satheesh
HI,
I have this code for InboundEmailHandler, which is working fine but i need to update more fields in contact object from email how we can do it.
for example:- I need to update phone number field from Email. 

global class SampleCreateContactEmailExample implements Messaging.InboundEmailHandler
{
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
    {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        Contact contObj = new Contact();
        try {       
            contObj = [select id, email,Subject__c, Email_Body__c, Phone, lastname   from contact where email =: email.fromAddress  limit 1];
        }
        catch(Exception e)
        {
            System.debug('************'+e.getMessage());
        }
        

        if(contObj.Id != null) 
        {
            contObj.Subject__c = email.subject;
            contObj.Email_Body__c  = email.plainTextBody;
            contObj.Phone=email.Phone;
        }
        else
        {
            contObj.lastname = email.fromName;
            contObj.email = email.fromAddress;
            contObj.Subject__c = email.subject;
            contObj.Email_Body__c  = email.plainTextBody;
        }                 
        upsert contObj; 
        
        // Insert attachments
        List<Attachment> lstAtt = new List<Attachment>();
                        
        if( email.textAttachments != null )
        {            
            for (Messaging.Inboundemail.TextAttachment txtAttachment : email.textAttachments) {
              Attachment attachment = new Attachment();
             
              attachment.Name = txtAttachment.fileName;
              attachment.Body = Blob.valueOf(txtAttachment.body);
              attachment.ParentId = contObj.Id;
              lstAtt.add(attachment);
             
            }
        }
               
        if( email.binaryAttachments != null)
        {
            
            for (Messaging.Inboundemail.BinaryAttachment binaryAttachment : email.binaryAttachments) {
              Attachment attachment = new Attachment();
             
              attachment.Name = binaryAttachment.fileName;
              attachment.Body = binaryAttachment.body;
              attachment.ParentId = contObj.Id;
              lstAtt.add(attachment);
            }
        }
               
        if(lstAtt.size() > 0)
            insert lstAtt;
            
        result.success = true;
        return result;
    }
}


Thanks
Satheesh
HI.

please any one help me ,

I create one vf page for displaying all the case related data along with check box for every record. using wrapper class , i display 10 records for every page like pagenation type,  first page i cheched 4 records displayed in other pageblocksection ,and click it second page or next button again checked 2 records and display it in same pageblocksection, but here my problem is i clicked previos button i saw the earlyier selected record which is unchecked. but i want check it

 
Hi All,

please help me regarding ,how to post test data and how to upload the attachment from salesforce to linkedin .

please guide me , if you have any code regarding this ,please share it to me.

Thanks
Satheesh
Hi All,

Please help me,
I got the information from linkedin and display it in VF page. but i want store those information in one custom object.

how to do this one ,
please find attached screenshot, here  first page block shows I fetched linkedin information,
second page block i created two custom fields in one custom object.

here there is no relationship between custom fields and linkedin field , please help me how to make relation or how to update custom fields with linkedin information . 

User-added image
Thanks
Satheesh
Hi All,

Please help me regarding integration between dropbox and salesforce ,

This Below link very useful to me  :
http://forceguru.blogspot.in/2014/05/dropbox-authentication-in-salesforce.html

but i am unable to get user profile information or app information from dropbox, please help me how to get those information , 

I did connection between salesforce to dropbox , i have access token ,api key, api secrete all things ,
but i don't know how pass request and how to get response as user details .


Please help me
Thanks
Satheesh

 
Hi All

Please help me regarding Create a flow , and how to test the flow,

Please give me steps for this

Thanks
Satheesh K 
HI,

please help me,

I want to migrate History tracking data from One instance to Another instance,
How can i migrate this data for all standard and Custom Objects,

I tried through data loader we can export history data but i tried to insert same data into same object there is no option for select the history object. 
please guide me , which is very urgent for my project.

Thanks
Satheesh
HI All,

please any one help me

I am a new for Migration process, please how to do migration ,what is the first step to start the process , before going to first step anything i need to understand ,  please help me and share any documents or pdf

Thanks
Satheesh
HI,
I have this code for InboundEmailHandler, which is working fine but i need to update more fields in contact object from email how we can do it.
for example:- I need to update phone number field from Email. 

global class SampleCreateContactEmailExample implements Messaging.InboundEmailHandler
{
    global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env)
    {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
        Contact contObj = new Contact();
        try {       
            contObj = [select id, email,Subject__c, Email_Body__c, Phone, lastname   from contact where email =: email.fromAddress  limit 1];
        }
        catch(Exception e)
        {
            System.debug('************'+e.getMessage());
        }
        

        if(contObj.Id != null) 
        {
            contObj.Subject__c = email.subject;
            contObj.Email_Body__c  = email.plainTextBody;
            contObj.Phone=email.Phone;
        }
        else
        {
            contObj.lastname = email.fromName;
            contObj.email = email.fromAddress;
            contObj.Subject__c = email.subject;
            contObj.Email_Body__c  = email.plainTextBody;
        }                 
        upsert contObj; 
        
        // Insert attachments
        List<Attachment> lstAtt = new List<Attachment>();
                        
        if( email.textAttachments != null )
        {            
            for (Messaging.Inboundemail.TextAttachment txtAttachment : email.textAttachments) {
              Attachment attachment = new Attachment();
             
              attachment.Name = txtAttachment.fileName;
              attachment.Body = Blob.valueOf(txtAttachment.body);
              attachment.ParentId = contObj.Id;
              lstAtt.add(attachment);
             
            }
        }
               
        if( email.binaryAttachments != null)
        {
            
            for (Messaging.Inboundemail.BinaryAttachment binaryAttachment : email.binaryAttachments) {
              Attachment attachment = new Attachment();
             
              attachment.Name = binaryAttachment.fileName;
              attachment.Body = binaryAttachment.body;
              attachment.ParentId = contObj.Id;
              lstAtt.add(attachment);
            }
        }
               
        if(lstAtt.size() > 0)
            insert lstAtt;
            
        result.success = true;
        return result;
    }
}


Thanks
Satheesh
HI.

please any one help me ,

I create one vf page for displaying all the case related data along with check box for every record. using wrapper class , i display 10 records for every page like pagenation type,  first page i cheched 4 records displayed in other pageblocksection ,and click it second page or next button again checked 2 records and display it in same pageblocksection, but here my problem is i clicked previos button i saw the earlyier selected record which is unchecked. but i want check it

 

Hi I'm trying to write test cases using isTest annotation

first of all i have initialized my visualforce page.

than initialized the controller

and iam calling each methods in controller

 

but in my code coverage is only 76% only....... i know 75% code coverage is enough for deploy code in production organization but iam expecting 100% code coverage here is my code please let me any suggesions

 

Here is mine Controller

in mine controller logic is reda csv file and display in to some vf page

 

//Create Controller For Import CSV File and Insert itnto Database
public class CSVcontroller {    
    public Blob uploadFile{ get; set; }
    public String nameFile { get; set; }
    public Integer colCount { get; set; }
    public String row {get; set;}
    public Integer rowCount { get; set; }
    public String fileString { get; set; }    
    //Insert Action for inserting the csv data into Fund_Management object
    @RemoteAction
    public static void insertAccounts(List<Fund_Management__c> fundlist){                 
        try{
            //Schema.DescribeFieldResult fId = Fund_Management__c.fnameMonthYear__c.getDescribe();
            //Schema.sObjectField T = fId.getSObjectField();
            Schema.SObjectField fId = Fund_Management__c.Fields.fnameMonthYear__c;
            //upsert(fundlist,fId,false);
            //insert fundlist;            
            //Database.Upsert(fundlist,fId,false);
              upsert fundlist fnameMonthYear__c;                      
            }catch(DmlException e) {
                System.debug('An unexpected error has occurred: ' + e.getMessage());
            }
       }
    
    public List<List<String>> getResults() {        
       List<List<String>> parsedCSV = new List<List<String>>();
       rowCount = 0;
       colCount = 0;
       if (uploadFile!= null){
            fileString = uploadFile.toString();       
            parsedCSV = parseCSV(fileString, false);
            rowCount = parsedCSV.size();
            for (List<String> row : parsedCSV){
               if (row.size() > colCount){
               colCount = row.size();
               }
            }
       }
       System.debug('nameFile' + nameFile);
       return parsedCSV;
     }
     public static List<List<String>> parseCSV(String contents,Boolean skipHeaders) {
         List<List<String>> allFields = new List<List<String>>();
         // replace instances where a double quote begins a field containing a comma
         // in this case you get a double quote followed by a doubled double quote
         // do this for beginning and end of a field
         contents = contents.replaceAll(',"""',',"DBLQT').replaceall('""",','DBLQT",');
         // now replace all remaining double quotes - we do this so that we can reconstruct
         // fields with commas inside assuming they begin and end with a double quote
         contents = contents.replaceAll('""','');
         // we are not attempting to handle fields with a newline inside of them
         // so, split on newline to get the spreadsheet rows
         List<String> lines = new List<String>();
         try {
         lines = contents.split('\r'); // using carriage return accomodates windows, unix, and mac files
         }
         catch (System.ListException e) {
         System.debug('Limits exceeded?' + e.getMessage());
         }
         Integer num = 0;
         for(String line: lines){
             // check for blank CSV lines (only commas)
             if (line.replaceAll(',','"').trim().length() == 0) break;
                 List<String> fields = line.split(',');
                 List<String> cleanFields = new List<String>();
                 System.debug('fields' + fields );
                 String compositeField;
                 Boolean makeCompositeField = false;
     
                 for(String field: fields) {
                     if (field.startsWith('"') && field.endsWith('"')) {
                     cleanFields.add(field.replaceAll('DBLQT',''));
                     }
                     else if (field.startsWith('"')) {
                     makeCompositeField = true;
                     compositeField = field;
                     }
                     else if (field.endsWith('"')) {
                     compositeField += ',' + field;
                     cleanFields.add(compositeField.replaceAll('DBLQT',''));
                     makeCompositeField = false;
                     }
                     else if (makeCompositeField){
                     compositeField +=  ',' + field;
                     }
                     else {
                     cleanFields.add(field.replaceAll('',''));
                     }
                }
                allFields.add(cleanFields);
            }
        //if (skipHeaders) allFields.remove(0);
        return allFields;     
     }
    public void checkblankfile(){
        if(rowCount == 0) {
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'The file is empty.'));
        }        
     }
    public PageReference vfReciredt(){         
        if(uploadFile ==null) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'Please Upload File'));
        }
        else{
            //PageReference redirect = new PageReference('/apex/Fund_List?sfdc.tabName=01r900000007xyR');
            //redirect.setRedirect(true);
            //return redirect;
        }
        return null;
    }

}

 

 highlighted area is not get covered anybody knows to get code coverage for that area..... and also let me know how to increase code coverage for code included in conditional statements like  for, if, else conditions

 

and here is mine Test class

 

@isTest
private class csvControllerTest
{    
   static testMethod void myUnitTest() {
        
        //Test converage for the cumulativePerformanceChart visualforce page        
        PageReference pageRef = Page.ImportCSV;
        Test.setCurrentPageReference(pageRef);          
        // Perform our data preparation.
        //Insert Single Record
        Fund_Management__c fmssr = new Fund_Management__c(Fund_Name__c='test fund',Growth__c=1.2,Month__c='Jan',Year__c=2008);
        insert fmssr;
        //Insert Bulk Record
        List<Fund_Management__c> fmsbr = new List<Fund_Management__c>{};
                 
        for(Integer i = 0; i < 200; i++){
            Fund_Management__c f = new Fund_Management__c(Fund_Name__c = 'Test Fund '+i,Growth__c = 1.2,Month__c = 'Jan',Year__c = 2008);
            fmsbr.add(f);
        }        
         //Now insert data causing an contact trigger to fire.
        Test.startTest();
        try {
             insert fmsbr;        
        }catch(DmlException e) {
           
            }       
        Test.stopTest();       
        // Query the database for the newly inserted records.
        List<Fund_Management__c> insertedFunds = [SELECT Fund_Name__c, Growth__c ,Month__c,Year__c FROM Fund_Management__c];             
        // Assert that the Description fields contains the proper value now.
        for(Fund_Management__c a : insertedFunds){
        System.assert(insertedFunds != null);
        }        
    
        String csvContent = 'Test,Jan,2001,3,l\nTest1,Feb,2001,4,k';
        //initialization of csvcontroller
        CSVcontroller csv = new CSVcontroller();
        List<List<String>> parsedCSV = CSVcontroller.parseCSV(csvContent,false);
        system.assertEquals(parsedCSV[0][0],'Test');
        system.assertEquals('Jan',parsedCSV[0][1]);
        system.assertEquals('2001',parsedCSV[0][2]);
        system.assertEquals('3',parsedCSV[0][3]);
        //Call All Methods In CsvController
         csv.getResults();
         csv.vfReciredt();
         csv.checkblankfile();           
         CSVcontroller.insertAccounts(fmsbr);
    }
}

 

in that i have write the insert logic for 1 records and insert logic for 200 records still not getting 100 % code coverage