web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Show Batch Job Error on the UI

(0) ShareShare
ReportReport
Posted on by 390

Hey team,

I have a form in which I save the data of the users which later is used to populate various tables through a batch job. This table has a field called "Status" which is initially "Pending" and changes to "Created" once the batch job has run successfully. If the batch job fails due to some reason the status is updated to "Failed". I want to show the front end user the Error which appears in the batch job logs when clicked on the status "failed". How can I do this? How can I show the errors of the batch job logs on the front end through x++?

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,037 Super User 2025 Season 2 on at

    Hi skd,

    Can't you use standard batch history form to show the errors to users? I do assume there is no relation between your table and the exact execution job which had the error.

  • skd Profile Picture
    390 on at

    Hi André Arnaud de Calavon ,

    Actually, batch job history can be seen by the technical users but my form is for non-techincal people so I just want to show them why the user creation failed. Is it possible?

  • André Arnaud de Calavon Profile Picture
    301,037 Super User 2025 Season 2 on at

    Hi skd,

    As mentioned, there is no relation between a specific batch execution and your table. You can consider creating a log field on your table which would store the error details. Then it will be most easy to present the details to the functional user.

  • skd Profile Picture
    390 on at

    Hey André Arnaud de Calavon ,

    I will create a log field on my table but how should I relate the batch job for that particular entry? Please can you elaborate how exactly can I achieve this?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    HI skd,

    While the table status is set to "Failed" in case of errors, can you not update the error log field in the table with the error from the batch job code?

  • skd Profile Picture
    390 on at

    Hey Gunjan Bhattacharyya,

    I didn't really get what you are trying to say.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    You have a table where the record status is "Pending" initially and is changed to "Created" when the batch job is run. In case of any errors, the status is changed to "Failed". Whenever there are errors and you update the status to "Failed", you can capture these errors and update the "Log" field as well in this table. You will need to include some additional logic in the batch job class to update the "Log" field with the error.

  • skd Profile Picture
    390 on at

    Thank you so much, I'm getting what you are saying also I was thinking how can I fetch the BatchJobID for a particular entry to show the logs.I will need batchjobID  as the showLog() function needs the RecID from the BatchJobHistory table. Can you suggest me how should I get the batchJobId for a particular entry.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    I am not sure if you can get the RecId of the BatchJobHistory table based on the record of the original table. Like Andre mentioned, you wouldn't have a direct relationship between your table and the BatchJobHistory table.

  • skd Profile Picture
    390 on at

    Okay, Thank you so much.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans