Launch another list form on field change

Home Forums Classic DFFS Launch another list form on field change

Viewing 12 reply threads
  • Author
    Posts
    • #17699
      Chris Diltz
      Participant

        I’m wondering if anyone has a solution that would launch a NewForm from another list in the site collection when a field is either (a) set to a specific value or (b) changes values. Use case: User answers a Yes/No question in parent form and must immediately be prompted to complete a child form (ticket) in a new dialog before moving forward with the current form. They must be prompted as we cannot rely on the user to click a button or navigate out to the child list.

        After the ticket(s) is/are created and the parent form completed, you could then use vLookup to tie the forms together.

      • #17736
        Alexander Bautz
        Keymaster

          Hi,
          It’s relatively simple to open a NewForm in a dialog from another form, but because of how the internal scripts that builds the lookup in the form works, you cannot refresh the list of available options without reloading the entire form (at least I don’t know how to do it).

          Does the “lookup” need to be a proper lookup, or could you use either the “SPJS-lookup” or the “SPJS-ac” script to get your lookup?

          Alexander

          • #17749
            Chris Diltz
            Participant

              I would use SPJS Lookup or Cascading Dropdowns on the child form but I’ve got that covered. I was more concerned with launching a child form based on a field change (or specific value selection) on the parent form, so the user is forced to complete the child form without relying on them to click a button/link. I attached an image that might explain. Hope that helps, and thank you for the quick response, Alex!

          • #17763
            Alexander Bautz
            Keymaster

              Just add this to the Custom JS and call the “openChildForm” function in a rule that triggers on “No” (in the “Run these functions / trigger these rules” field):

              function openChildForm(){
                  SP.UI.ModalDialog.showModalDialog({
                      "url":"/DFFS/Lists/DFFS_TestList/NewForm.aspx",
                      "showMaximized":false,
                      "allowMaximize":true,
                      "showClose":true,
                      "dialogReturnValueCallback":function(status){
                          if(status === 1){
                              // form was saved - do something?
                          }
                      }
                  });
              }

              Alexander

            • #17767
              Chris Diltz
              Participant

                Thank you sir! I will give this a shot. Is there a way to append this in order to prepopulate columns on the child form (similar to vLookup)?

              • #17773
                Alexander Bautz
                Keymaster

                  You can pass the values in the URL like this:

                  SP.UI.ModalDialog.showModalDialog({
                          "url":"/DFFS/Lists/DFFS_TestList/NewForm.aspx?Title=Put your string here&AnotherField=Put the string here",
                  ...
                  ...

                  Then in the NewForm Custom JS add this code:

                  var urlTitle = GetUrlKeyValue("Title");
                  if(urlTitle !== ""){
                      setFieldValue("Title",urlTitle);
                  }
                  // Repeat for your other fields

                  PS: Thanks for the beer!

                  Alexander

                • #17893
                  Chris Diltz
                  Participant

                    I have the basics of this working. Thanks so much!

                    I do have a couple amateur questions (apologies):
                    1) how do I pass a value to the child form from a column in the parent item?
                    2) After saving the child NewForm, the parent form content shrinks to the top half of the dialog (with scroll bars). Do you know of a way to retain the content/dialog proportions on the parent form?

                    Thanks, in advance.

                  • #17915
                    Alexander Bautz
                    Keymaster

                      1: See my code snippet from August 16:

                      “url”:”/DFFS/Lists/DFFS_TestList/NewForm.aspx?Title=Put your string here&AnotherField=Put the string here

                      The “Title” and “AnotherField” are the parameters you pass in the URL. If want to insert the current value from the parent form here, user it like this:

                      “url”:”/DFFS/Lists/DFFS_TestList/NewForm.aspx?Title=getFieldValue(“Title”)&AnotherField=getFieldValue(“AnotherField”)

                      2: Are you using anything in the “dialogReturnValueCallback” function? You may be able to use this:

                      spjs.dffs.resizeDlg();

                      Alexander

                    • #17917
                      Chris Diltz
                      Participant

                        The dialog resize function works perfectly – thank you! I am getting a javascript error on the form when I replace the string with the “getFieldValue” portion. I’ve tried using the FIN and friendly/display name of the column.

                      • #17925
                        Alexander Bautz
                        Keymaster

                          I think my snippet was wrong – try this:

                          "url":"/DFFS/Lists/DFFS_TestList/NewForm.aspx?Title="+getFieldValue("Title")+"&AnotherField="+getFieldValue("AnotherField"),
                          ...
                          ...

                          Alexander

                        • #17931
                          Chris Diltz
                          Participant

                            The string values are working fine but I still can’t get the parent form values to pass in the URL. I’m no longer getting any error messages, just not seeing the values populate.

                          • #17933
                            Chris Diltz
                            Participant

                              FYI, I have also tried FIN and display names of the parent/child columns to no avail.

                            • #17935
                              Chris Diltz
                              Participant

                                What about setting a variable on the parent side and passing that variable in the URL?

                              • #17937
                                Chris Diltz
                                Participant

                                  I got it working now, disregard. You had it right, Alex – thanks so much for your help.

                              Viewing 12 reply threads
                              • You must be logged in to reply to this topic.