Server Script - After Insert Problem, Not Equal to Created?

Hello,

I’m trying to use the After Insert event on a server script bu tit doesn’t appear to work, as I’d expect.

Plan

  • When a new Batch is created from a Purchase Receipt I want the server script to run and modify the newly created Batch entry.
  • I created a server script to test which uses the DocType Event: After Insert on the Batch DocType, to simply fill in a custom field with the value “Test” and save the change.
doc.custom_supplier_identifier = "Test"
doc.save
  • When I create a new batch via the Purchase Receipt, the server script doesn’t trigger
  • If I change the server script to be triggered by After Save, make a minor change to the Batch entry and save it, the server script works as expected and adds “Test” to the custom field.

So am I missing how the DocType Event After Insert works? Should it not be triggered by the creation/insertion of a new record?

Thanks,
Paul

Did you find a solution to this?
If so, could you please share it here.

Hi,

Not sure if this will fit your scenario but the server script in the post does work for my scenario.