I have an object "shipment__c" with fields, among others, "CIF_Value__c", "Exporter_Account__c", "Shipment_Account__c", "Invoice_Name__c". I have another object called "Account_Move_c" with fields "Amount_c", "From_account__c", "To_Account_c", "Description_c".

I'm trying to automatically create a record on "Account_Move_c" each time a record on "Shipment_c" is either created or updated. It doesn't seem too complicated to do, but I'm stuck on how to call the variables related to "Shipment__C".

Here is how I've attempted:

trigger AccountingMoveLoading2 on Shipment__c (after insert) {
    List<Accounting_Move__c> listaccountingmove = new List<Accounting_Move__c>();
    for (Shipment__c oShippment : trigger.New) {
        Accounting_Move__c oAccounting_Move = new Accounting_Move__c();
        oAccounting_Move.Accounting_Move_Date__c = oShipment.ETD__c;
        oAccounting_Move.Accounting_Move_Description__c = oShippment.Invoice_Name__c;
        oAccounting_Move.From_Account__c = oShippment.Exporter_Name__c;
        oAccounting_Move.To_Account__c = oShippment.Shipment_Account__c;
        oAccounting_Move.Transaction_Amount__c = oShippment.CIF_Value__c;
    insert listaccountingmove;

and I'm getting this error. Any ideas?

Error:Apex trigger AccountingMoveLoading2 caused an unexpected exception, contact your administrator: AccountingMoveLoading2: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, From_Account: id value of incorrect type: a05b00000045RNDAA2: [From_Account__c]: Trigger.AccountingMoveLoading2: line 14, column 1

2 Answers 2


Franky, Field From_Account__c is probably expecting an Account object (id), but your are passing it Exporter_Name__c which is possibly a String. Rup

  • You were absolutely right, I've selected the wrong field from the object. Thanks a lot.
    – Franky
    Dec 25, 2013 at 12:55

Pls check the spelling of oShippment. It has a double 'p' in the for loop and in your assignment you are using oShipment.ETD__c . There is only one 'p' there


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.