Get Subform Index of field when it changes

评论

5 条评论

  • Avatar
    Casey Kolowinski

    I solved my initial problem by just updating ALL rows with [*] but it doesn't actually solve my issue, it's just a good enough workaround that it doesn't break my form. So if anyone has any suggestions, I'm all ears.

    0
    评论操作 固定链接
  • Avatar
    sysberry GmbH

    Hi Casey,

    you can try to trigger a rule from the subform where as a parameter you set "this". After that in JS code you can find in which row is this "this" is comming from and then work with that row.

    Regards

    Alexey

    1
    评论操作 固定链接
  • Avatar
    Casey Kolowinski

    Hi sysberry GmbH,

    Thank you for taking the time to respond. I'm unsure how you are able to isolate just "this" as a parameter, or directly within the JS code. Do you perhaps have a screenshot or example that you could show?

    Thanks,

    Casey

    0
    评论操作 固定链接
  • Avatar
    Casey Kolowinski

    I was able to throw together the below to get the index of the currently affected row:

    var thisField = $ctrl;
    var index;
    var curParent;
    var child;

    for (var i = 0; i < thisField.parents('.subFormContentRowChildWrapper').parents('.subFormContent').children('.subFormContentRow').length; i++)
    {
    curParent = thisField.parents('.subFormContentRowChildWrapper').parents('.subFormContent').children('.subFormContentRow')[i];
    child = $(curParent).find("#" + thisField[0].id);
    if (child.length !== 0)
    {
    index = i;
    break;
    }
    }

    • However, it didn't give me the correct behavior. It was "Successful" but didn't trigger the formula as expected when I tried to run the below:

     

    • NOTE: my workaround is to throw * inside the brackets on line 2 below and it works fine. Not sure why the indexed value doesn't work.
    var options = {};
    options.fieldId = 'sf_LineItems/rtfx_LineItemTotalXchange:[' + index + ']';
    eFormHelper.triggerFormula(options, function (result)
    {
    if (result.isSuccess)
    {
    console.log(result.data); //logs the data holds the empty object
    }
    else
    {
    console.log(result.error); // logs the hold exception object
    }
    });
    0
    评论操作 固定链接
  • Avatar
    Casey Kolowinski

    UPDATE and solved!

    I didn't realize I could create an "options.rowIndex = index;" property. Doing this allowed me to take the brackets out of the FieldID option and it works as expected now.

    0
    评论操作 固定链接

请先登录再写评论。