Home › Forums › Classic DFFS › Launch another list form on field change
- This topic has 13 replies, 2 voices, and was last updated 7 years, 4 months ago by Chris Diltz.
-
AuthorPosts
-
-
August 10, 2017 at 14:11 #17699
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.
-
August 14, 2017 at 19:42 #17736
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
-
August 15, 2017 at 15:19 #17749
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!
Attachments:
-
-
August 16, 2017 at 18:29 #17763
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
-
August 16, 2017 at 18:54 #17767
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)?
-
August 16, 2017 at 20:38 #17773
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
-
August 21, 2017 at 17:02 #17893
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.
-
August 23, 2017 at 23:53 #17915
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
-
August 24, 2017 at 12:13 #17917
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.
-
August 25, 2017 at 00:02 #17925
I think my snippet was wrong – try this:
"url":"/DFFS/Lists/DFFS_TestList/NewForm.aspx?Title="+getFieldValue("Title")+"&AnotherField="+getFieldValue("AnotherField"), ... ...
Alexander
-
August 25, 2017 at 12:12 #17931
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.
-
August 25, 2017 at 12:14 #17933
FYI, I have also tried FIN and display names of the parent/child columns to no avail.
-
August 25, 2017 at 12:18 #17935
What about setting a variable on the parent side and passing that variable in the URL?
-
August 25, 2017 at 15:45 #17937
I got it working now, disregard. You had it right, Alex – thanks so much for your help.
-
-
AuthorPosts
- You must be logged in to reply to this topic.