Get Subform Index of field when it changes
I have a Subform with a few fields in it. I'm trying to set something up where if field X changes, do a bunch of stuff in Custom JS.
The problem that I'm running into is that my custom JS doesn't seem to be able to handle running against the current row of the subform that I'm in.
So I need a way to tell what row of the subform field X is in when it changes, so that I can use that value in my subsequent code.
Anyone have any thoughts?
Thanks,
Casey
-
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
}
});
請登入寫評論。
評論
5 條評論