Update the Doctype based on changes in a child table

Hi,

I have a doctype Events and Participants/Customers. What I would like to achieve is to update the value of a checkbox “Attended” in the Participants Document if Participants/Customers is added on the Events Child Table

Hi there,

Generally speaking, you can implement something like this easily with a server script, responding to the “Save” event on your Events doctype.

Specifically here, I would suggest considering an Events link field over a checkbox, as checkboxes won’t hold any reference to the Event attended. If it gets deleted, the participant doctype won’t automatically be updated.

https://docs.erpnext.com/docs/v13/user/manual/en/customize-erpnext/server-script

Thanks for the Response, If you mind, would you further explain how can this be done?
Should we do something like this?

update_member = frappe.get_doc(‘Participants 2022’, members_dict.get(i.name).name)
update_member.full_name = i.full_name
update_member.first_name= i.first_name
update_member.middle_name = i.middle_name
update_member.last_name = i.last_name
update_member.attended= 1
update_member.save()

I don’t really understand your workflow or what the Participants 2022 doctype looks like, so it’s hard for me to know what your code is doing. What does members_dict refer to, and what is i?

Doctype A = Members
Doctype B = Events
Child Doctype B = Participants

We are trying to update a check box “Attended” in “Doctype A” if Members are added in the Participants Table

Yep, I got that part. What I don’t understand is, what is “Participants 2022”, what is “members_dict”, and what is “i”? Where are these defined?

Hi BB_CORP,

on click of update button you should have value in support link field if not present means its shown error like this so you pls check support link field value

Still same issue occurred even if the field has value on the table

Hi @BB_CORP,

I think a name is a primary key so it’s not updating.
Please try with a custom field then after checking set a value.

Thank You!

Is there anyway this can be done?

To reiterate what I said before, it’s not obvious to me how your code is supposed to be working, but I don’t know whether the problem is your misundersatnding of the frappe API or my misunderstanding of your doctypes.

It’s not possible for us to look at this code in isolation and answer your questions. For example, you’re now talking about a doctype called “Hermosa Support 2022”, but you haven’t told us what that is. What happened to “Participants 2022”? And what about the “Events” doctype you’ve said you’re using? How many doctypes do you have here? Are you sure you’re clear on the difference between a Document and a Doctype?

If you want to answer the questions I asked in my last post, we can try to help you, but right now you’re not giving us the information we need to do that.