Loop within loop

Comments

3 comments

  • Avatar
    Scott Bennett

    So, AP is working on this issue since I have run into this issue. Let me first explain about repeating subforms that contain repeating subforms:

    So let's say you have a repeating Subform A and in that you have another repeating Subform B
    A
     B
     B1
    A1
     B2
     B3

    So I have a loop to go through A and inside A I have a loop to go through B. The first time you get results for B you get all of them
    B, B1, B2, B3 even though you are in Subform A and would want only B and B1

    This is the way it currently works but they are working on fixing this

    The following JS can help in setting file ids in order to determining which subform the upload is occurring in

    function PrepareLoopIndex() {
    var fileData = {};
    // console.log ("PrepareLoopIndex started");
    eFormHelper.getSubFormData({ "fieldId": "NUFUploadOtherFilesSub" }, function (res) {

    if (res.isSuccess) {
    jQuery(res.data).each(function (i, d) {
    var itemIds = ""; jQuery(d.NUFUserFileUpload_MultiFile.NUFUserFileUpload).each(function (ind, data) {
    itemIds=itemIds+','+data.itemId;
    });
    fileData["StoreFileIDs_" + i] = itemIds;
    });
    }
    });

    eFormHelper.getField({ fieldId: "NUFUploadOtherFilesSub/StoreFileIDs:[*]" }, function (res) {
    if (res.isSuccess) {
    jQuery(res.data).each(function (i, d) {
    var controlId = jQuery(d).attr("id").split('-')[0] + "_" + i;

    eFormHelper.setFieldValue({ fieldId: jQuery(d).attr("id"), value: fileData[controlId] },
    function (result) {

    });
    });
    }
    });
    }

     

    In your workflow you can just use their loop controls and ut one inside another...  sorry not an easy solution

    1
    Comment actions Permalink
  • Avatar
    Edit Toth

    Thank you, it works!

    0
    Comment actions Permalink
  • Avatar
    Loren Bratzler

    I know this is probably a long-shot, but this post from 2 years ago describes exactly the problem I am having that I posted about in this thread:

    https://helpdesk.agilepoint.com/hc/en-us/community/posts/360018014273

    I am working with a Sub-Form that has a file upload control in it.  If the user attaches files on a specific row of the sub-form, I need for those files to be kept separate from files attached on other rows of the sub-form.  So I need some way to identify which row of the sub-form an attached file belongs to.

    I don't really understand what is going on in the JavaScript that Scott posted or when the script would be executed.

    And Scott mentioned that AgilePoint was working on a solution to the problem where when you loop through a child sub-form, you get all the child entries regardless of which parent they belong to.  Is this really being worked on?  Since this was from two years ago, I suspect that it is not.

    0
    Comment actions Permalink

Please sign in to leave a comment.