DFFS rule/required field based on items in child list

Home Forums vLooup for SharePoint DFFS rule/required field based on items in child list

Viewing 2 reply threads
  • Author
    Posts
    • #14137
      AdamP
      Participant

        I’ve had a request to improve a form so that it can only be saved if an entry has been created in a vLookup child list. Is there any functionality that would allow this to easily be achieved?
        It doesn’t matter how many entries there are as long as there are more than zero – essentially making the vLookup column into a required field on the parent form.

        Thanks

        Adam

      • #14190
        Alexander Bautz
        Keymaster

          Hi,
          You can use the “spjs.vLookup.dataObj” to check if there are any child items. Use the function like this:
          I have updated the code snippet in the below comment.
          Change “The_name_or_your_vLookupField” to match your vLookup field.

          Alexander

        • #21861
          Alexander Bautz
          Keymaster

            I’m editing this old post because there was an error in the original comment.

            function dffs_PreSaveAction(){
                var hasChildren = false;
                if(spjs.vLookup.dataObj["The_name_or_your_vLookupField"] !== undefined && spjs.vLookup.dataObj["The_name_or_your_vLookupField"][spjs.dffs.data.thisItemID] !== undefined && spjs.vLookup.dataObj["The_name_or_your_vLookupField"][spjs.dffs.data.thisItemID].count > 0){
                    hasChildren = true;
                }
                if(!hasChildren){
                    alert("You must add a child item before you can save this item");
                    return false;
                }
                return true;   
            }

            Alexander

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