Change values in parent form and call pnp after the save of sub form (child list DT)

Hello what is the best way to do the following:
I need to change values of controls in main form and do PNP to get multiple values from a list and insert the values in main/parent form too.

but i need to do this after save of the child sub form not before save

fd.spBeforeSave(function () {
NOT Here
});

what about :
fd.spSaved(function () {
** is it the best place to do the following:**
pnp.sp.web.lists.getByTitle("List").items.select("Id", "Title", "CtrlName").filter(filter).get().then((rtrnPnp) =>.....
window.top.fd.field('ctrlName01').clear();
window.top.fd.field('ctrlName02').value = rtrnPnp.CtrlName (PNP Result)
});

i tried but i failed
kindly advise

Hello @gkhadra,

Sorry for the delay in reply. We had a national holiday.

If you need to run the script after the item is saved, you need to use it under fd.spSaved() event handler. That is right.

But it is not clear for me what you want to perform after the item is saved. Do you want to update the parent form when the child item is saved? Do you want to pass the values from the child element to the parent?

Could you please provide more details and share the code you have. Screenshots of the form would also be helpful.

Hello @mnikitina,

Thank you for you reply.
I solved my problem in another way but.

But i am interested to know how to do the following under fd.spSaved() event handler, if you can just give me an example it will help to use this event in another form:

  • How to update the parent form when the child item is save?

  • How to pass the values from the child element to the parent?

is it the same scripts like:
fd.spSaved(function () {
window.top.fd.field('ctrlName01').clear();
window.top.fd.field('ctrlName02').value = fd.field('child control value').value;

Sometimes i will use pnp instead of child control value in order to get data from other list and fill the parent form control
});

What i need to take into consideration to achieve this without errors, do i need to add Settimeout function()
kindly advise

@gkhadra,

You can pass values from the child item, which is opened in the dialog box, to the parent with this code:

window.top.fd.field('ParentTitle').value = fd.field('ChildTitle).value;

And it is up to you, you can either use it under spBeforeSave() or spSaved(). For example:

fd.spSaved(function(spForm) {
var parentForm = window.top.fd;

parentForm.field('TitleParent').value = fd.field('TitleChild').value;

});

You can find more information about event handlers here:
https://plumsail.com/docs/forms-sp/javascript/manager.html#events

Regarding the PNP, it depends on what item you want to return. Please provide more details so we could suggest something.