Java script to update text from cascading lookups in a repeating subform

Comments

5 comments

  • Avatar
    Scott Bennett

    have you tried :[this]

    0
    Comment actions Permalink
  • Avatar
    Randy Crundwell

    Yes - that is where we started.  It did not update any of the data.  We added the 1 and got a value on testing one row.

    Good question - I should have noted that in my initial description.

    0
    Comment actions Permalink
  • Avatar
    Scott Bennett

    So, I used the other Form events handler to set fields but requires you to know what section you are on. If you only have one page it is simpler... This event fires off on ANY subform that is added...

    eFormEvents.subForm.onAddRecord = function ()
    {
    console.log("Entering the subform event");
    console.log('subformonAddRecord arguments', arguments)
    var control = getfieldValue('SHPSelPage');
    console.log("subformcontrol: ", control,'\n');
    if (control === 'CPA')
    {
    console.log("CPA Section Detected");
    console.log('onAddRecord arguments[0].dataName', arguments[0].dataName)
    eFormHelper.showLoader({value : true},function(res){ });
    setMandatory('CreApChooseAreaofInterest/CreApCollectionType',true);
    };
    eFormHelper.showLoader({value : false},function(res){ });
    console.log("End of the subform event");
    };

    0
    Comment actions Permalink
  • Avatar
    Randy Crundwell

    Scott.  Thanks for the reply.   I need to admit up front that I know nothing about java...

    I can follow some of the purpose of the script, but am still not seeing how it would deal with the unique lines of the sub form as it repeats?  Can you offer some explanation, or adjust to show how it would work?    Is this function called on each individual 'record' (instance of a new row being added / saved within the sub form) and as such not necessary to know the row number?  If so, how does it properly determine the instance of the destination fields within the sub form?

    Still confused...

     

    0
    Comment actions Permalink
  • Avatar
    Scott Bennett

    I was new to JS before I started this also. What you surmise is correct. The event handler goes off when a row(subform) is added so at that point no need to know what row you are in. In the example I have a form with many sections which is controlled in JS to hide and show the tabs. The check there is to determine which section I am in. Since an eForm with multiple sections is still considered a single form and the event handler goes off when a row is added on the form I need to figure out where I am first.

    I was thinking you would use the get and set field handlers there to populate your data.

    I have to admit I have had problems with subforms in general and rules/autolookups that apply to them. In general it seems that rules and autolookups work only when the form loads or the user makes a change. I have a lookup that waits for a change that doesn't execute when the field is filled in by another lookup. I can see the change and the lookup doesn't execute. Although the field changes in a section that isn't visible so not sure if that has something to do with the lookup executing. If I make that field visible and editable and type something in the field the autolookup executes... go figure.

    There are other problems if you have repeating subforms within repeating subforms that AP is currently working on. Not sure if what you are running into fits into this category...

     

     

    0
    Comment actions Permalink

Please sign in to leave a comment.