Create maintanance schedule automatically after submitting sales invoice

Hi All,

My actual requirement:

I want the maintenance schedule to be automatically created once a sales invoice is submitted.

Customer name,items,start date are available in the sales invoice and end date is ‘start date + 1 year’ and no of visits is fixed to 2.

Is this possible by calling an api in custom script in sales invoice? ( cant use server scripts as we dont want to setup our own server instead signup for a plan on erpnext.com)

What I am trying to do

I am able to read all the existing maintanance schedules using below code…

I tried to update an existing record using below code and ran into an error

(Also I tried to create a record in ‘Branch’ doctype ( for the sake of simplicity)as it has only one field and again ran into an error )

Is my approach right? If so what changes I need to make in my code? Thanks

Make a server side app and add a “on_submit” hook