{"action":"created","issue":{"url":"https://api.github.com/repos/afawcett/apex-sobjectdataloader/issues/11","labels_url":"https://api.github.com/repos/afawcett/apex-sobjectdataloader/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/afawcett/apex-sobjectdataloader/issues/11/comments","events_url":"https://api.github.com/repos/afawcett/apex-sobjectdataloader/issues/11/events","html_url":"https://github.com/afawcett/apex-sobjectdataloader/pull/11","id":62389679,"number":11,"title":"RecortType Support","user":{"login":"afaubel","id":9460319,"avatar_url":"https://avatars.githubusercontent.com/u/9460319?v=3","gravatar_id":"","url":"https://api.github.com/users/afaubel","html_url":"https://github.com/afaubel","followers_url":"https://api.github.com/users/afaubel/followers","following_url":"https://api.github.com/users/afaubel/following{/other_user}","gists_url":"https://api.github.com/users/afaubel/gists{/gist_id}","starred_url":"https://api.github.com/users/afaubel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afaubel/subscriptions","organizations_url":"https://api.github.com/users/afaubel/orgs","repos_url":"https://api.github.com/users/afaubel/repos","events_url":"https://api.github.com/users/afaubel/events{/privacy}","received_events_url":"https://api.github.com/users/afaubel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-17T13:01:29Z","updated_at":"2015-03-20T09:08:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/afawcett/apex-sobjectdataloader/pulls/11","html_url":"https://github.com/afawcett/apex-sobjectdataloader/pull/11","diff_url":"https://github.com/afawcett/apex-sobjectdataloader/pull/11.diff","patch_url":"https://github.com/afawcett/apex-sobjectdataloader/pull/11.patch"},"body":"This is an attempt to add record type support. It includes details of the records types from the source org by adding these to the bundle. Then when the records are de-serialised the code uses the name related to the record type ID to try and find a record type in the destination org. The following is a test used to cover this functionality:\r\n\r\n```\r\n    /**\r\n     * @description Test record type support\r\n     **/\r\n    static testMethod void testContactExportRecordType() {\r\n\r\n        // Get the record types for the contact object\r\n        Map<String, Id> recordTypeIdMap = new Map<String, Id>();\r\n        for (RecordType rt : [SELECT Id, DeveloperName FROM RecordType WHERE sObjectType='Contact']) {\r\n            recordTypeIdMap.put(rt.DeveloperName, rt.Id);\r\n        }\r\n\r\n        // Create an account\r\n        Account acc = TestFactory.createAccount('Acc 1');\r\n        insert acc;\r\n\r\n        // Create a couple of contacts with different record types\r\n        Map<Integer, Contact> contactMap = new Map<Integer, Contact>();\r\n        Contact contact1 = TestFactory.createContact('Fred', 'Bloggs', acc.Id); \r\n        contact1.RecordTypeId = recordTypeIdMap.get('DDC_Recruiter');\r\n        contactMap.put(1, contact1);\r\n        Contact contact2 = TestFactory.createContact('Tony', 'Bloggs', acc.Id); \r\n        contact2.RecordTypeId = recordTypeIdMap.get('Standard');\r\n        contactMap.put(2, contact2);\r\n        insert contactMap.values();\r\n\r\n        // Start the test\r\n        Test.startTest();\r\n        \r\n        // Create the JSON data from this test account\r\n        String exportJSON = SObjectDataLoader.serialize(new Set<Id>{contactMap.get(1).Id,contactMap.get(2).Id});\r\n        System.debug('@@@ JSON : ' + exportJSON);        \r\n\r\n        // Test the JSON to ensure the correct values are included\r\n        System.assert(exportJSON.contains('Acc 1'));\r\n        System.assert(exportJSON.contains('Fred'));\r\n        System.assert(exportJSON.contains('Tony'));\r\n        System.assert(exportJSON.contains(recordTypeIdMap.get('DDC_Recruiter')));                \r\n        System.assert(exportJSON.contains(recordTypeIdMap.get('Standard')));       \r\n        System.assert(exportJSON.contains('DDC_Recruiter'));\r\n        System.assert(exportJSON.contains('recordTypeMap'));\r\n\r\n        // Now replace the ID string for one of the record types and see if that can be imported OK\r\n        String exportJSON2 = exportJSON.replaceAll(recordTypeIdMap.get('DDC_Recruiter'), '012w00000002XXO'); // Just a random Id\r\n        System.debug('@@@ JSON2 : ' + exportJSON2);     \r\n\r\n        // Check that the replace has worked\r\n        System.assert(exportJSON2.contains(recordTypeIdMap.get('DDC_Recruiter'))==false);                \r\n        System.assert(exportJSON2.contains(recordTypeIdMap.get('Standard')));       \r\n        System.assert(exportJSON2.contains('012w00000002XXO'));       \r\n\r\n        // Delete the two contact records\r\n        delete contactMap.values();\r\n\r\n        // Now try and deserialise these records\r\n        Set<Id> newRecordIds = SObjectDataLoader.deserialize(exportJSON2);\r\n        System.assertEquals(1, newRecordIds.size());\r\n\r\n        // Stop the test\r\n        Test.stopTest();\r\n\r\n        // Get the contacts and test values\r\n        List<Contact> contactList = [SELECT Id, RecordTypeId, FirstName FROM Contact];\r\n        System.assertEquals(2, contactList.size());\r\n        for (Contact c : contactList) {\r\n            if (c.FirstName == 'Fred') {\r\n                System.assertEquals(recordTypeIdMap.get('DDC_Recruiter'), c.RecordTypeId);\r\n            } else if (c.Firstname == 'Tony') {\r\n                System.assertEquals(recordTypeIdMap.get('Standard'), c.RecordTypeId);\r\n            } else {\r\n                System.assert(false, 'Not a valid test record');\r\n            }\r\n        }\r\n\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/afawcett/apex-sobjectdataloader/issues/comments/83960245","html_url":"https://github.com/afawcett/apex-sobjectdataloader/pull/11#issuecomment-83960245","issue_url":"https://api.github.com/repos/afawcett/apex-sobjectdataloader/issues/11","id":83960245,"user":{"login":"Sonal4J","id":6659484,"avatar_url":"https://avatars.githubusercontent.com/u/6659484?v=3","gravatar_id":"","url":"https://api.github.com/users/Sonal4J","html_url":"https://github.com/Sonal4J","followers_url":"https://api.github.com/users/Sonal4J/followers","following_url":"https://api.github.com/users/Sonal4J/following{/other_user}","gists_url":"https://api.github.com/users/Sonal4J/gists{/gist_id}","starred_url":"https://api.github.com/users/Sonal4J/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sonal4J/subscriptions","organizations_url":"https://api.github.com/users/Sonal4J/orgs","repos_url":"https://api.github.com/users/Sonal4J/repos","events_url":"https://api.github.com/users/Sonal4J/events{/privacy}","received_events_url":"https://api.github.com/users/Sonal4J/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T09:08:26Z","updated_at":"2015-03-20T09:08:26Z","body":"@afawcett  I have not made a fix for this"}}