Hi community,
I’m working on a custom LMS workflow where users (employees) should submit a Course Enrollment Request, and only after their manager approves it, the user should be enrolled in the course.
Here’s the current flow:
- When a user clicks “Start Learning,” a
Course Enrollment Request
with status “Pending” is created. - An email is sent to the assigned manager for approval.
- But the problem is: the user still gets enrolled immediately after clicking “Start Learning,” even though the manager hasn’t approved the request yet.
I realized that the backend wasn’t strictly checking for the request’s Approved status before enrolling the user. This breaks the approval logic completely.
To fix this, I’m now thinking of separating the logic:
- One function to only create the enrollment request.
- Another function to handle the enrollment only if approval is confirmed.
Is this the right approach? Or is there a better, more Frappe-idiomatic way to enforce manager-based approval before enrollment?
Looking forward to suggestions.
Thanks!