Home › Forums › vLooup for SharePoint › vlookup List / Item and Parent List Rules or Custom JS
- This topic has 8 replies, 2 voices, and was last updated 4 years, 5 months ago by Jeremy Smith.
-
AuthorPosts
-
-
May 6, 2020 at 23:17 #29833
Hello group,
I am wondering how I might be able to trigger a rule or customer JS when using a vlookup list on a parent form. What I would like to do is click a button that pulls up the vlookup list am_SysTrackingReqDetails (using Add New Item Button function of the vlookup form in DFFS). on this form I have a field SystemRequest. What I would like to do is after updating the am_SysTrackingReqDetails form and click save, that upon clicking save and closing down the window, it captures the value of the SystemRequest field and allows me to post it into a field on the Parent form called StatusUpdatesNot sure how to upload images here so I will try and paint a picture:
Parent Form (has many fields – will only depict the fields I am concerned about):
SPFieldNote – StatusUpdates
SPFieldText – vLookupReqNum – this Add New Item button opens another list called am_SysTrackingReqDetailsam_SysTrackingReqDetails Form:
SPFieldText – Title (aka Tracking Number)
Save Button – save the new list item and close the form1) From the parent form, launch the am_SysTrackingReqDetails form using the Add New Item button.
2) Enter the details into all the fields on the new item (am_SysTrackingReqDetails form)
3) Click Save button (am_SysTrackingReqDetails form)
4) Trigger a rule or custom JS script to copy the value from the Title field on the am_SysTrackingReqDetails form and paste into the StatusUpdates field on the Parent formthoughts about how to do this? I tried to search the forum, but do not think I am asking the right questions to get the right forum return responses
-
May 7, 2020 at 18:56 #29868
Hi,
You can try the method I describe here: https://spjsblog.com/forums/topic/have-the-child-item-populate-the-parent/#post-28561Let me know how it works out.
Alexander
-
May 13, 2020 at 22:36 #29956
I tried to adjust the code to work for what I was looking to do and it doesn’t seem to work.
I built a temporary field for testing called YOUR_COUNTER_FIELD on the parent form
I have my vlookup Child Form on the same pageI added to the parent form this modified code:
setInterval(function() { var currCount = getFieldValue("YOUR_COUNTER_FIELD"); var newValue = tracknum; setFieldValue("YOUR_COUNTER_FIELD", newValue); },1000);
and went into the vlookup child form and added this modified code:
function dffs_PreSaveAction(){ var tracknum = getFieldValue("Title"); window.parent.tracknum return true; }
When I launch the child form from the parent, it pulls up in a small dialog window in front of the parent form.
I fill out the form field on the child (internalname = Title) and click save
it then brings me back to the parent form and I click save
it exits to the main list of items and I reopen and the field YOUR_COUNTER_FIELD is still blankI am not sure what I am doing incorrect, but then again, I am still learning here 🙂
-
May 13, 2020 at 22:47 #29958
Attached a screenshot of the setup
Attachments:
-
May 14, 2020 at 11:34 #29966
I tidied up the code a bit and corrected a few issues:
// Parent form var setTracknumInterval = setInterval(function () { if(typeof tracknum !== "undefined"){ setFieldValue("YOUR_COUNTER_FIELD", tracknum); clearInterval(setTracknumInterval); } }, 1000); // Child form function dffs_PreSaveAction() { var tracknum = getFieldValue("Title"); window.parent.tracknum = tracknum; return true; }
Alexander
-
May 14, 2020 at 19:03 #29975
Thank you for making the tweaks for this. It appears to be working as expected with the little bit of testing I have performed. If anything changes, I will reach back out. Again, thank you 🙂
-
May 14, 2020 at 21:05 #29981
Thanks for the update – I’m glad it worked out.
Alexander
-
June 10, 2020 at 18:03 #30580
After further testing, I am having trouble understanding why it isn’t executing. So once I click the Vlookup table and create an item, it carries back the items in the code and places the data into the parent form field. However, now if I go to edit the new item again, it doesn’t carry over the new changes made in the pop-up child form back to the parent:
Tried the following to test:
Trial 1:
– Create a new parent form
– Click the vlookup to create child pop-up form
– Edit child form and click save
– Pulls in original values from child to parent form field
– Without saving Parent form, click the vlookup child form edit button and launch child form pop-up
– edit and save
– Nothing changes to parent form, not even triggering the parent form js codeTrial 2:
– Create a new parent form
– Click the vlookup to create child pop-up form
– Edit child form and click save
– Pulls in original values from child to parent form field
– Save parent form and exit
– Reopen same parent itme
– Click the vlookup child form edit button and launch child form pop-up
– edit and save
– Nothing changes to parent form, not even triggering the parent form js codeCurrent code
Parent:
//Add content from child window to parent window field var setTracknumInterval = setInterval(function () { if(typeof tracknum !== "undefined" && typeof dCreated !== "undefined" && typeof rStatus !== "undefined" && typeof rFormType !== "undefined"){ var newCounterField = getFieldValue("YOUR_COUNTER_FIELD"); alert(newCounterField); alert(rStatus); setFieldValue("YOUR_COUNTER_FIELD", rFormType + ":" + tracknum + " : Date Created: " + dCreated + " : " + rStatus + "---" + newCounterField); clearInterval(setTracknumInterval); } }, 1000);
Child Code:
function dffs_PreSaveAction() { var tracknum = getFieldValue("Title"); var dCreated = getFieldValue("DateCreated"); var rStatus = getFieldValue("Status"); var rFormType = getFieldValue("SystemRequest"); window.parent.tracknum = tracknum; window.parent.dCreated = dCreated; window.parent.rStatus = rStatus; window.parent.rFormType = rFormType; return true; }
What needs to be modified to make happen
-
June 10, 2020 at 20:16 #30583
Nevermind my request for help. I realized I had not put similar code into the EditForm of the child pop-up window, only the NewForm. so nothing was triggering when I would edit.
Once I added the code, it seemed to work. Still running more tests currently
- This reply was modified 4 years, 5 months ago by Jeremy Smith.
-
-
AuthorPosts
- You must be logged in to reply to this topic.