Any solution to make webform render jinja code?
Hi
Throw in an html field in your webform then use Client Scripts to inject your content into.
Much cleaner way is to make the webform part of your custom app.
Also, you are trying to render doc.creation but the document does not exist while you are filling the webform, it is inserted after you submit the form.
Additionally, this seems like a one-time agreement/contract. Why would you create a webform for that?
If you are a little bit technical (or know how to prompt an AI) you can utilize Print Formats to act as forms specific to a document.
From system settings if you enabled “older web view links” your document can be publicly accessed at {% frappe.get_url() + '/' + doc.doctype + '/' + doc.name + '?key=' + frappe.get_doc(doc.doctype, doc.name).get_signature() %}
So simply you can create a custom print format with completely customized HTML/CSS with your own input fields beside jinja-rendered content. So basically a completely custom web page scoped within a record.
To accept data you can use JS within the print format to call a publicly accessible endpoint (can be created via Server Scripts) but make sure to rate limit it and restrict it properly based on document signature and whether fields has already been filled.
Additionally if data is already filled you can utilize jinja if/else blocks to prevent rendering the form again. So once your client visits this link back they will see a digital copy of their contract but cant modify it anymore.
@Yamen_Zakhour Thanks for your comment. I already have the print format with my agreements.
My problem is that I’ve four agreements, and I need the user (Customer) to sign them.
I thought of having a web form with the agreement rendered in an HTML field and a signature field below.
Webforms are meant to accept public data like surveys or whatever, they insert records rather than updating existing ones. Someone can actively visit the same url to submit more records into your database.
Technically it’s possible to achieve what you want in webforms using a bunch of hidden fields, hooks and stuff but that’s pretty hacky.
My proposed solution was to create a CUSTOM print format and utilize HTML/CSS/JS/Jinja to create a public web-view for your doctype. That is much more secure and scoped within the document you want them to sign
However if you are developing a custom app, there are much better and easier solutions
There is this but im not sure if you can render your print E-sign-App/README.md at master · asoral/E-sign-App · GitHub
Thanks for helping so far.
Yes, I’m creating a custom app.
Creating a public web view is great, but I’m facing an issue rendering the signature field in the web view.
If there is a less code solution, please share your ideas with me. Thank you.
I edited the above comment to link to an e-sign frappe app but im not sure if it renders a print view of the document.
Regarding my proposed solution
- In your current print formats, wrap the signature area with an if/else jinja block to either render the signature form if empty or otherwise display the signature
- If not signed —> display a signature field. So you dont reinvent the wheel use this signature pad library (via CDN) GitHub - szimek/signature_pad: HTML5 canvas based smooth signature drawing
- Create a whitelisted signature API endpoint on your custom app. The endpoint would basically verify that the document signature exists (the token in the url), and that document has not been signed then update the signature field of the document (You will need POST to share base64 via API)
That’s the entire setup, you would share the public view url with your clients to sign
Amazing, thanks a lot.
