Possible to AUTOMATICALLY create new doctype record?... from a template?... using a scheduler/cron?

Let’s pretend we create a new doctype called "reminder"

(I do not use “todo” as example since this is a real core doctype)

So we have our doctype reminder and reminders will have this minimal set of fields for this example:

reminder.id
reminder.reminder_description
reminder.remind_this_user
reminder.instructions
reminder.duedate
reminder.generated_from_tmpl_id // if created automatically the id of the tmpl (see below) used

So maybe we use reminder.duedate to send some notifications to remind_this_user. Ok fine, let’s pretend that’s the complete app. Great! If we only wanted directly created entries. But maybe we want to have some of these reminders generated on schedule for us, automatically?..


Now what if I what to make another doctype called reminder_template and in this doctype I have some of the the pre-filled fields in “reminder” doctype above:

reminder_tmpl.id
reminder_tmpl.reminder_description
reminder_tmpl.remind_this_user
reminder_tmpl.instructions
reminder_tmpl.duedate_days (i.e. “30” = duedate will be +30 days from when reminder is created)

as well as these fields for the reminder generator / scheduler…

reminder_tmpl.generate_startdate // the first date it will create this reminder
reminder_tmpl.generate_enddate // the last date it will create this reminder i.e. 12/31/9999
reminder_tmpl.generate_interval_days // (i.e. 365 = 1 year)
reminder_tmpl.generate_frequency // (ie. frequency 12, interval_days 365 = monthly reminder)
reminder_tmpl.generate_next // the next date this reminder should be generated

Does this scheduler / generator type of functionality exist in frappe or erpnext already? Any type of doctype record creator that will autmatically create a new record based on a pre-defined template like this?

If I’m understanding your goals correctly, it seems like this would be fairly straightforward to accomplish using server scripts.

Set a server script scheduled to run daily (or even hourly), iterate through your reminder templates, and generate the reminders you need for the next period.

Would that serve your needs?

1 Like

You can also try Auto Repeat

Reference: https://docs.erpnext.com/docs/v13/user/manual/en/automation/auto-repeat

1 Like

Yeah this would seem like a way to get it done quickly…

The problems I see would be:

  • Since “Auto Repeat” function doesn’t have a “Target Document Type” , then you cant have seperate doctype for your templates (i.e. ‘reminder_templates’ live with ‘reminders’ in same doctype).

  • Could get around this with [x] Is auto repeat template field on the templates I guess, then filter these in all the reports. It’s just a bit sloppy to do it this way.

It helps that it has option to start as draft mode though [ ] submit on creation.

It might be easier to clone and make a custom version of auto repeat for this. Something that will target different doctype than the source (where field names match).

@peterg Yes, this is exactly what I’m trying to do.