Block document creation through form. Only creation via code allowed

Hi All, Team,

I’ve created a DocType that I would only like to be updated only programmatically. I would like to block the creation of documents through the Forms for the doctype. Is this possible without relying on permissions?
Any ideas are welcome.

Regards,
CKSGB

You can check a flag that you can set programatically

def validate(self):
  if not self.flags.can_update: raise Exception

When you call

doc.flags.can_update = True
doc.save()

flags cannot be set via API and are cleared explicitly even if they are set.

@Chude_Osiegbu, in the doctype, you can mark the option, User Cannot Create, by the UI