How to pass parameters (values) from Dialogue form to the parent form on close and save

Hello I have a scenario where i need to pass multiple values from the dialogue form to the parent form i am missing something.
kindly find my code below

//Sub form
//**********************************************
////Pass Param After save
//**********************************************
fd.spSaved(function (result) {
    //if opened in dialog
    if (window.frameElement && Dialog.getArgs()) {
        var strSigneeName = fd.field("OutgoingLogPersonSignee").value;
        var strSigneeTitle = fd.field("OutgoingLogPersonPosition").value;
        var blSigneeIsBishop = fd.field("SigneeIsBishop").value;
        var strPlaceOfIssue = fd.field("PlaceOfIssue").value;
        var dtSader = fd.field("OutgoingLogDate").value;

        //PassParam with new ID
        Dialog.close(true, {ID: result.Id, ParamSigneeName: strSigneeName, ParamSigneeTitle: strSigneeTitle, ParamSigneeIsBishop: blSigneeIsBishop, ParamPlaceOfIssue: strPlaceOfIssue, ParamSaderDate: dtSader });
    }
});

    //*************************************************
    //Parent form
    //**********************************************
    fd.field("BaptismRecordTypeIdFk").ready().then(function () {
        return fd.field("BaptismRecordTypeIdFk").ready();
    }).then(function () {
        return fd.field("BaptismRecordParishNameIdFk").ready();
    }).then(function () {
        $('.clsOutgoingNewTrs').on('click', function () {
            var intRecordTypeID = fd.field("BaptismRecordTypeIdFk").value.ID;
            var intParishID = fd.field("BaptismRecordParishNameIdFk").value.ID;
            var strVillageTxt = fd.field("BaptismRecordVillageName").value;
            var strDescription = fd.field("Title").value;
            var strFullLink = "";

            //Open form and Pass Parameters
            //To change the site link in case of application cloning to another client
            strFullLink = "/sites/XXXXXXX/Lists/XXXXXX/newform.aspx";
            Dialog.open(strFullLink,
            //{ ParmParentForm: 'BaptismForm', ParmRecordTypeID: intRecordTypeID, ParmParishID: intParishID, ParamVillage: strVillageTxt, ParmDescription: strDescription }, function (hasSaved, newID) {
            { ParmParentForm: 'BaptismForm', ParmRecordTypeID: intRecordTypeID, ParmParishID: intParishID, ParamVillage: strVillageTxt, ParmDescription: strDescription }, function (hasSaved,returnedArgs) { 
                if (hasSaved) {
                    //Set OutgoingID
                    fd.field("BaptismRecordCertOutgoingID").widget.dataSource.read();
                    //fd.field("BaptismRecordCertOutgoingID").value = newID;
                    fd.field("BaptismRecordCertOutgoingID").value = returnedArgs.ID;
                    //Set Signee Data From Param
                    fd.field("BaptismRecordCertGivenByName").value = returnedArgs.ParamSigneeName;
                    fd.field("BaptismRecordCertGivenbyJobTitle").value = returnedArgs.ParamSigneeTitle;
                    fd.field("PersonSigneeIsBishop").value = returnedArgs.ParamSigneeIsBishop;
                    fd.field("BaptismRecordCertPlaceOfIssue").value = returnedArgs.ParamPlaceOfIssue;
                    fd.field("BaptismRecordCertFromEparchy").value = returnedArgs.ParamSOnBehalf;
                    fd.field("BaptismRecordCertGivenDate").value = returnedArgs.ParamSaderDate;
                }
            }, { width: 800, height: 800 });
        });
    });

Hello @gkhadra,

How do you open the dialog window? Are you opening the dialog from List or Library control?

Dear @mnikitina

I am opening the dialogue from a control in the parent form/List as follow:

I have in the parent form a lookup field:

fd.field("BaptismRecordCertOutgoingID")

This field is disabled all the time, user cannot open and select a value from this lookup directly.
Instead I created a Button control and gave it a Class: clsOutgoingNewTrs (kindly check the code above)

Where a dialogue form related to the lookup field will open in order to create a new item and fill data.
On save in return i will get values and i will use it:

  • First to refresh the lookup field and set the value automatically

              fd.field("BaptismRecordCertOutgoingID").widget.dataSource.read();
              fd.field("BaptismRecordCertOutgoingID").value = newID;
    
  • Second i will set fileds in parent form equals to values returned from the dialogue form

now my problem is how to pass the values as parameters

this one alone is working properly:

            fd.field("BaptismRecordCertOutgoingID").widget.dataSource.read();
            fd.field("BaptismRecordCertOutgoingID").value = newID;

but i am facing a problem when i need to pass multiple values

            fd.field("BaptismRecordCertOutgoingID").widget.dataSource.read();
            //fd.field("BaptismRecordCertOutgoingID").value = newID;
            fd.field("BaptismRecordCertOutgoingID").value = returnedArgs.ID;
            //Set Signee Data From Param
            fd.field("BaptismRecordCertGivenByName").value = returnedArgs.ParamSigneeName;
            fd.field("BaptismRecordCertGivenbyJobTitle").value = returnedArgs.ParamSigneeTitle;
           etc

thank you

Hello @gkhadra,

Do you mean that the BaptismRecordCertOutgoingID field is a multiple choice lookup field and you want to populate it with multiple values?

Dear @mnikitina

Thank you again for your support.
No it is not what i mean.
I will try again to explain my request i appreciate your patience.

If you check the link below:
https://plumsail.com/docs/forms-sp/javascript/dialog.html

You can find in the Method:
close(bool, args)

This code:
if (window.frameElement && Dialog.getArgs()){
Dialog.close(true, {ID: result.Id });
}

Where on dialogue close, the parameter {ID} will be passed.

My need is:
-How to pass multiple parameters from the dialog form to the parent not only the ID.
-How to get/catch these multiple parameters on the parent form.

Thank you

@gkhadra,

spSaved returns only the ID of the saved item.

You can populate other values using the item ID and PnPjs, or save all values in the local storage before save:

1 Like

Thank you again for the infomration
It is good to take into consideration in future a way to allow passing parameters from a dialogue form like we do from parent form easier and less coding.

I used the following in my case:
Change values in parent form

fd.spBeforeSave(function () {
    if (window.frameElement && Dialog.getArgs()) {
        //Set Parent Fields values
        //*************************
        window.top.fd.field('PersonSigneeIsBishop').value = fd.field("SigneeIsBishop").value;
        window.top.fd.field('BaptismRecordCertPlaceOfIssue').value = fd.field("PlaceOfIssue").value;
    }
1 Like