Specifically, I’m trying without success to put multiple conditions of an “on_change” webhook for a Sales Invoice.
What works:
doc.status != "Draft"
doc.xml_file != "Home"
What fails:
eval: doc.status != "Draft"
eval:!(doc.status == "Draft")
eval: (doc.status != "Draft")
doc.xml_file != "Home",
doc.status != "Draft"
doc.xml_file not null and doc.status != "Draft"
doc.xml_file is not null and doc.status != "Draft"
doc.xml_file != "Home" && doc.status != "Draft"
!doc.xml_file
Questions:
Is it JavaScript? What vintage of Javascript?
Is it SQL? Can I use anywhere clause condition function?
is it Python?
When is eval necessary?
Where do base*1 and inlist come from?
Where are the docs?
Where’s the code?
My guess is depends_on is in the asyncio_posix.py MVC event loop?
eval() is a builtin function to evaluate REPL “read-eval-print loop” Python eval() Function
LOL yup Python and JS is kinda primitive, this ain’t Smalltalk - the batteries included code browser, builtin debugger, MVC, the full meal deal environment
It looks to me like the WebHooks developer went, “Oh, WebHooks need to be constrained by conditions!. COOL I’ve always wanted an excuse to develop my own Domain Specific Language. Yay!”
I’m really not in the mood to go spelunking something like that to figure out what it permits and what it doesn’t.
Except I cannot find a way to include it that the WebHooks doctype validator doesn’t immediately reject.
That’s not helpful.
Nope. Not SQL either. It might be a Frappe created MariaDb Stored Procedure. Who the fuck knows. Oh, hey it is a function in R language!! Well sheeee-it … conditions have to programmed in R! There ya go. Obvious once you see it.
I don’t know if you have understood what I have been working on.
Below I have posted a component diagram to clarify the main elements of the sequence diagram that follows it. They show the focus of my efforts for weeks now.
I think the record of my questions here shows that I have had to dedicate at least an entire day sometimes 3 or 4 days, picking through forum posts for each new major step in the operations shown:
Create new DocType as installed app.
Launch and Configure NodeJs app from within new DocType
Use socketio with NodeJs (complete fail, documented example does not work)
Hook action in Node Js from internal event with conditions
Customize DocType
Attach File to DocType
Obtain Record through API
Update Record through API
Including having to deal with yet more initial install and startup issues I have been at it for over three weeks.
The record also shows that I have tried to post complete functioning, useful solutions to the documentation deficiencies I encountered in every step of the process.
This nonsense with “conditions” was the last straw. I think I’ve earned the right be a tiny bit indelicate.
So the condition field uses Python and the code you can write in here is
exactly what is allowed inside any “condition” in Python (like in if condition).
This is the same reason why multiple lines wont work, as python doesnt accept linebreaks in conditions without escapes.
If the conditions are many, then you will have to use and, or or or others like below, without linebreaks: a==b and b!=c or c!=a and c>b
Trying now this to send a welcome message to the customer as a condition for a Sales Order:
"package pro small" in [d.item_code for d in doc.get("items")] \
or "package pro medium" in [d.item_code for d in doc.get("items")] \
or "package pro large" in [d.item_code for d in doc.get("items")]