I’ve create a custom script that makes some math and set some values in fields automatically.
It makes this when a document is submitted, via UI, but it don’t seem to work when I use the API to create the document.
Can someone tell me is there’s a way to use the REST API methods to create a document and also run the changes that the custom script do? Does it work only in the UI?
I guess this may work in other cases, but mine is a little too specific, you see, I have a whole other system that will consume data from my custom app in frappe, and when it does, I want to create a document with the data that was in that document at that time, plus with some others that will be calculated in the moment according with some of the data.
I already made a workaround for this issue by using first a POST to create the document, then in the other system I make the decisions and all, and finally then I call a PUT request to update the fields with the information I needed. I just wish I could do this in one go… Just call a POST request, already changing the document status to 2, and the Custom Script would run and make everything in one go.
But it was just a shot in dark, because being a the Custom Scripts, basically, a javascript, I had little hopes for this to be possible.
If you need the operation to be purely client side, OP has already described the solution. If you can use Server Scripts, the process can be much simpler.