0

I have used object.clone() here and then changed some field values. All the changes are reflected in the cloned record except not able to populate External Id field which is concatenation of two Id fields Survey_Question_vod__c & ':' & Survey_Target_vod__c from the parent object. Please suggest where it goes wrong.

if(s1qs2qMap.get(s1q1r.Survey_Question_vod__c)!=null && 
    s1Ts2TMap.get(s1q1r.Survey_Target_vod__c)!=null ) { 
    Question_Response_vod__c clonedRecord = s1q1r.clone();
    clonedRecord.Survey_Question_vod__c=s1qs2qMap.get(s1q1r.Survey_Question_vod__c);
    clonedRecord.Text_vod__c = s1q1r.Text_vod__c;
    clonedRecord.Type_vod__c = s1q1r.Type_vod__c;

    clonedRecord.Survey_Target_vod__c = s1Ts2TMap.get(s1q1r.Survey_Target_vod__c);
    clonedRecord.External_Id_vod__c = s1qs2qMap.get(s1q1r.Survey_Question_vod__c)+
        ':'+s1Ts2TMap.get(s1q1r.Survey_Target_vod__c);
    s2q1rListToInsert.add(clonedRecord);
}
  • what is the type of External Id ? I think it should be text, not ID – Ilya Lepesh May 6 '16 at 12:43
  • Yes it is a text field – Testing_SFDC May 6 '16 at 12:43
  • what is the length ? – Ilya Lepesh May 6 '16 at 12:44
  • it has 120 size which is enough to incorporate two 18 digit Id field – Testing_SFDC May 6 '16 at 12:50
  • I'm not able to reproduce. If you change s1q1r.clone(); to new Question_Response_vod__c(); doesit work ? – Ilya Lepesh May 6 '16 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.