Expense must have a value in Source Code Setup: Primary Key=. It cannot be zero or empty.

Expense must have a value in Source Code Setup Primary Key=. It cannot be zero or empty.
Expense must have a value in Source Code Setup Primary Key=. It cannot be zero or empty.

Error Message

After clicking Post on ER0002 [Expense Report], Business Central shows the error and the report is not posted.

    Error on posting Expense Report ER0002

    Cause in Source Code Setup

    Source Code Setup tells Business Central which Source Code to stamp on the entries of each area. For Expense Management the setting is Expense in the Employees section. If it is empty, the posting cannot continue.

    Open Source Code Setup and scroll to the Employees section. The Expense field is empty.

    Expense field empty in the Employees section

    Solution

    Create a Source Code for expenses if you do not have one yet. In Source Codes, add a new line, for example EXPENSE with the description Expense.

    New Source Code EXPENSE in Source Codes

    Open Source Code Setup, go to Employees, and select EXPENSE in the Expense field.

    EXPENSE selected in the Expense field, Source Code Setup

    Result

    Post ER0002 again. The Expense Report is posted as PER0002 and moved to Posted Expense Report.

    Expense Report posted as PER0002

    If posting then stops with another error, it is a different missing setup item and not related to the Source Code. The Employee Posting Group and the Expense Posting Group must also have their G/L accounts filled in.

    Hope so this is Helpful 😃

    By Ahmad Subhani

    Microsoft Dynamics 365 and Business Central consultant sharing practical insights, new features, product reviews, and real-world solutions for modern businesses.

    Leave a Reply

    Your email address will not be published. Required fields are marked *