Expand my Community achievements bar.

How to make Expanding Fields mandatory

Avatar

Level 3

Hi,

I'm trying to make an expandable table whose fields are mandatory if a selection to make the table visible is selected.

For instance, if the user selects "Yes" to a radio button, the table becomes available showing 4 rows that I want to make mandatory ONLY if the table is visible. I have accomplished that by entering the following code

if (this.rawValue == "1") {

Extras.Participants.Info.Last.mandatory = "error";

Extras.Participants.Info.First.mandatory = "error";

Extras.Participants.Info.IUID.mandatory = "error";

Extras.Participants.Info.Date.mandatory = "error";

}

else {

Extras.Participants.Info.Last.mandatory = "disabled";

Extras.Participants.Info.First.mandatory = "disabled";

Extras.Participants.Info.IUID.mandatory = "disabled";

Extras.Participants.Info.Date.mandatory = "disabled";

}

However, the problem I have is that the table is dynamic and once the button to create a new instance (row) on the table is clicked, the new row is not showing the red border as a mandatory fields.

Is there a way to make the new instances to inheret the mandatory command???

Thank you!!!!

6 Replies

Avatar

Level 6

Cant you just make the fields "required" under the value tab? Are you just checkign ot make sure data is entered the field? Or, ar oyu using the script to "turn-off" the red box upon data insertion?

Avatar

Level 3

Hi,

Thank you for your reply. Actually, the fields are conditional to appear by clicking on a radio button (I should have included that in the original code. see below for full code). I only want them to be required if they are visible. Making them required under the value tab will prevent the form to be submitted even if they are invisible. What the code I sent in my previous email is lacking is the ability to make any new instances required.  When the radio button is selected, it displays the table and it shows the existing (1st row) as required but only works for that first row since when I add another instances (row)  they do not become required. I was hoping there was a way to make any

subsequent row to be required.

Thank you for your help!!!

if (this.rawValue == "1") {

Extras.presence = "visible";

Extras.Participants.Info.Last.mandatory = "error";

Extras.Participants.Info.First.mandatory = "error";

Extras.Participants.Info.IUID.mandatory = "error";

Extras.Participants.Info.Date.mandatory = "error";

}

else {

Extras.presence = "hidden";

Extras.Participants.Info.Last.mandatory = "disabled";

Extras.Participants.Info.First.mandatory = "disabled";

Extras.Participants.Info.IUID.mandatory = "disabled";

Extras.Participants.Info.Date.mandatory = "disabled";

}

Avatar

Level 10

I am assuming the repeating row is "Info";

If you still have issues, then share the Heirarchy by highlighting the Repeating row name.

var intIndex = Extras.Participants.Info.instanceManager.count-1; // Get the index of the last row.

var oSubform = Extras.Participants.resolveNode("Info["+ intIndex "]"); //Resolve the path to the recently added row.

if (this.rawValue == "1") {

Extras.presence = "visible";

oSubform.Last.mandatory = "error";

oSubform.First.mandatory = "error";

oSubform.IUID.mandatory = "error";

oSubform.Date.mandatory = "error";

}

else {

Extras.presence = "hidden";

oSubform.Last.mandatory = "disabled";

oSubform.First.mandatory = "disabled";

oSubform.IUID.mandatory = "disabled";

oSubform.Date.mandatory = "disabled";

}

Thanks

Srini

Avatar

Level 3

Hi Srini,

Thank you for your reply. That's correct!! The repeating row is called "Info". this is how it goes. Extras = subform, Participants = Table name, Info = Row name. However, when I pasted your code it did not work. The form (Extras) was not even displaying..

Is there something I may have missed?

Thank you for your help!!!

Avatar

Level 10

Sorry I missed the "+" after the intIndex in the 2nd line of code..

Here is the corrected script.

var intIndex = Extras.Participants.Info.instanceManager.count-1; // Get the index of the last row.

var oSubform = Extras.Participants.resolveNode("Info["+ intIndex + "]"); //Resolve the path to the recently added row.

if (this.rawValue == "1") {

Extras.presence = "visible";

oSubform.Last.mandatory = "error";

oSubform.First.mandatory = "error";

oSubform.IUID.mandatory = "error";

oSubform.Date.mandatory = "error";

}

else {

Extras.presence = "hidden";

oSubform.Last.mandatory = "disabled";

oSubform.First.mandatory = "disabled";

oSubform.IUID.mandatory = "disabled";

oSubform.Date.mandatory = "disabled";

}

Thanks

Srini

Avatar

Level 3

Hi Srini,

Again, thank you very much for you response. However, it still does not work. It makes the first row required but when I click the button to add another row, the new row gets added without the red frame around the fields.

I appreciate all your help!!!

J