You need to sign in to do that
Don't have an account?
Vigneshwaran Loganathan
Calling Batch Apex from Class for DML
Hello,
I have to bulk insert in two objects which are parent and child. I have mapped parent's external id to child records.
I'm calling batch apex from normal class which inserts both. But Child records cant able to find parent External ID as it runs in parallel instead of one after one.
Error : System.DmlException: Upsert failed. First exception on row 0; first error: INVALID_FIELD, Foreign key external ID
Is there a way to achieve this.? please suggest me if there are alternatives.
Thanks
Vignesh
I have to bulk insert in two objects which are parent and child. I have mapped parent's external id to child records.
I'm calling batch apex from normal class which inserts both. But Child records cant able to find parent External ID as it runs in parallel instead of one after one.
Error : System.DmlException: Upsert failed. First exception on row 0; first error: INVALID_FIELD, Foreign key external ID
public static void saveFile() { Try { if(FinalTarList.size()>0) // Parent { SPL_BatchImportGild splTar = new SPL_BatchImportGild(FinalTarList); // should execute first Database.executeBatch(splTar,200); success = true; } if(FinalcycdetCopy.size() > 0) { SPL_BatchImportGild splTarDet = new SPL_BatchImportGild(FinalcycdetCopy); // should execute after parent Insertion. Database.executeBatch(splTarDet,200); } } }
Is there a way to achieve this.? please suggest me if there are alternatives.
Thanks
Vignesh
All Answers