vlookup List / Item and Parent List Rules or Custom JS

Forums vLooup for SharePoint vlookup List / Item and Parent List Rules or Custom JS

Viewing 8 reply threads
  • Author
    Posts
    • #29833
      Jeremy Smith
      Participant

      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 StatusUpdates

      Not 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_SysTrackingReqDetails

      am_SysTrackingReqDetails Form:
      SPFieldText – Title (aka Tracking Number)
      Save Button – save the new list item and close the form

      1) 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 form

      thoughts 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

    • #29868
      Alexander Bautz
      Keymaster

      Hi,
      You can try the method I describe here: https://spjsblog.com/forums/topic/have-the-child-item-populate-the-parent/#post-28561

      Let me know how it works out.

      Alexander

    • #29956
      Jeremy Smith
      Participant

      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 page

      I 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 blank

      I am not sure what I am doing incorrect, but then again, I am still learning here ๐Ÿ™‚

    • #29958
      Jeremy Smith
      Participant

      Attached a screenshot of the setup

    • #29966
      Alexander Bautz
      Keymaster

      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

    • #29975
      Jeremy Smith
      Participant

      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 ๐Ÿ™‚

    • #29981
      Alexander Bautz
      Keymaster

      Thanks for the update – I’m glad it worked out.

      Alexander

    • #30580
      Jeremy Smith
      Participant

      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 code

      Trial 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 code

      Current 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

    • #30583
      Jeremy Smith
      Participant

      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 1 month, 3 weeks ago by Jeremy Smith.
Viewing 8 reply threads
  • You must be logged in to reply to this topic.