You need to sign in to do that
Don't have an account?
How to insert using Test.LoadData
I have created a CSV file and using Test.Load data I am able to get the corresponding record of the object.But my question is When I will require to insert a record of a object which is related to the earlier inserted object, how will I use Test.load data...Exmp
I have inserted Account object related data using Test.Load data.But in the same test method I need to insert Contact object related record.How will I do it?
I have tried in the following way....
List<sObject> ls = Test.loadData(Account.sObjectType, 'testAccounts');
Account a1 = (Account)ls[0];
List<sObject> con = Test.loadData(Contact.sObjectType, 'TestContacts');
Contact newContact=(Contact)con[0];
newContact.accountid=a1.id;
update newContact;
Any way around??????????????
newContact.Account = a1;
update newContact;
to setup the relationship, then you will get everything.
I know that this is an old topic but this is how I solved the issue:
One thing to remember is that you will not be able to reference a record being loaded in the same CSV file. So you couldn't create a parent account with the Id "0" and a child account with a ParentId of "0" in the same file. You can however, load your parent account CSV, then load your child account CSV.
I hope this helps to simplify your solutions.