Update data in an existing DocType record through a web form

Example Scenario:

I have added some custom fields, such as Phone Number, Documents (Child Table), Address, etc to the Job Applicant Doctype. I want to capture these details from applicants through a Web Form since they do not have access to the Desk. Additionally, I want to update these details in the existing Job Applicant Doctype.

Is there a way to achieve this?

Get all fields in the webform and check it.

Then you can easily update the existing data without using the desk.

I don’t wanna get custom fields in Current webform I want to update existing record

My Case

  1. HR Manager will create a Job Applicant record (e.g. HR-JP-******)
  2. If an applicant is shortlisted then in same record(HR-JP-***) I want to collect applicant details(Phone Number, Documents (Child Table), Address, etc) for which I have created a new web form with fields Phone Number, Documents (Child Table), Address, etc

Not sure, but you can try with a server script.

for now I have applied my custom logic in validate function and it is working as expected, but while going through web_form.py code I’ve found something related to update existing record.

But I haven’t found any steps to implement this.

I’m suggesting you try with a normal server script. When the web form is saved, it will basically save the data to a doctype. So, when the doctype is saved, you can update the data using doc_events. Give it a try. (Not tested, but maybe it should work.)

If I will do in after save event then it will create a new record in doctype and I don’t want to create a new record I want to update the data in the existing record :sweat_smile: .

same thing you can do with doc_events.

have you tried?
How will you know without trying?

You have to apply logic and only you know where I want to update so think a little.

I think you didn’t understand my case. I have already tried using the “after save” event; it is creating a new record through the webform. I don’t want to create a new record; I want to update an existing record, which the HR Manager created.

Hello @ejaaz , have you solved this issue? I’m doing the similar task on Employee DocType. Can you share me the solution?

Hi @ducminhgd
I have made a server call in the validate method in js and saved the form data manually by passing the unique name in the form. I took code from this function, modified it a little, and after saving the data, returned false in the validate function.