Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Make Table Field Required When Other Table Fields are Filled In

mlstechwriter71
Level 2
Level 2

Good Morning,

After combing through the forums I couldn't find an answer for the the following scripting scenario.

(Or maybe I am asking the wrong question)

I have a Table (Name: InputTable) with a Header Row, and a footer Row (for a Grand Total Function), Add/Delete buttons, as well as Addition scripts.

The client has requested that if a dollar amount is put in one or any of Cell4, Cell5, Cell6, Cell7, Cell8, Cell9 or Cell10
Then Cell1 becomes a required field.

This Table must have an Initial count of 10 Rows, so I can't simple make Cell1 a Required field, because there could be blank/empty rows being submitted, and that would fire errors.

Could someone please provide an example of the Script I would need to Add to Row1, Cell1? (Or the resources of where to look)
And can this script be made to work on all Rows Added?

I don't do alot of scripting and I could sincerely use help on this.

Thank you all in advanced, I appreciate you taking time to help me out!

-Michelle

1 Accepted Solution
Magus069
Correct answer by
Level 10
Level 10

alright well because when you calculate, your total always have to be the last line or else i dont think it reads the line below the total

so do something like this

View solution in original post

9 Replies
Magus069
Level 10
Level 10

Euhmmm... so if you change the value of one of the cells 4-10 you want cell1 to be required... so

verify all your cells if their value is (rawValue != null)

if only one is different then null use this to change the required field of Cell1:

Cell1.mandatory = "error";     //cell 1 is mandatory

Cell1.mandatory = "disabled";     //cell1 is optional

mlstechwriter71
Level 2
Level 2

Okay, now you are really going to be able to tell how little I do scripting, lol..

The Script: 
rawValue != null

does this go on the individual cells 4-10?

Or does all of this scripting go on Cell1

rawValue != null
Cell1.mandatory = "error";     //cell 1 is mandatory

Cell1.mandatory = "disabled";     //cell1 is optional

Sorry if the question seems really basic - but thats totally me

Thank you for your help!

mlstechwriter71
Level 2
Level 2

I think I have a better way to ask my question, and it may make for simplier coding.

Can someone advise on how I would I code javascript for this scenario:

Sample.png

Looking for Javascripting For: If a number appears in the Total cell, the Job # cell becomes required.

I'm assuming that the javascript would be on the Total cell and would be on a '"Calculate" event?

Thanks again for the help!

Magus069
Level 10
Level 10

Yea, it should be something like so...

If you are using Calculate event for Total... when you insert the value, verify if it's higher than 0

Your language should be in FormCalc for Calculate event so, it should be like this:

//Here you have your code to calculate the value and insert it in the total field.

if ($.rawValue gt 0) then

     $.resolveNode("Job").mandatory = "error"

else

     $.resolveNode("Job").mandatory = "disabled"

endif

mlstechwriter71
Level 2
Level 2

Well, I goofed something up, but it's not firing any error.

It just doesn't trigger any warnings, nothing happens at all... lol. Even When I hit the Submit Form Button to email it.

Anyone have suggestions on what I did wrong?

And I was wondering: The Job # field is marked User-Optional. I think that's correct for what I am trying to do here.

Sample2.jpg

Here's what I have:

 

TopmostSubform.Page1.InputTable.Row1.Total::calculate - (FormCalc, client)

sum (Sun+Mon+Tues+Wed+Thurs+Fri+Sat)

//Mandatory Field

if($.rawValue gt 0) then
  $.resolveNode("Job").mandatory = "error"
else
  $.resolveNode("Job").mandatory = "disabled"
endif

And the Sum function also stopped working... lol. I'm not having a good week with this form.

As Always, I am grateful for the assitance, thank you!

-Michelle

Magus069
Level 10
Level 10

"Sum" function is normally used to calculate all rows... you should just write: Sun+Mon+Tues+Wed+Thurs+Fri+Sat

mlstechwriter71
Level 2
Level 2

Okay, corrected the calculation - so Sum in now gone:

TopmostSubform.Page1.InputTable.Row1.Total::calculate - (FormCalc, client)

Sun+Mon+Tues+Wed+Thurs+Fri+Sat

//Mandatory Field

if($.rawValue gt 0) then
$.resolveNode("Job").mandatory = "error"
else
$.resolveNode("Job").mandatory = "disabled"
endif

However if I keep this information from //Mandatory Field on down, the table will not calculate, and the mandatory coding doesn't do anything.

Is there something else I might be missing?

Magus069
Correct answer by
Level 10
Level 10

alright well because when you calculate, your total always have to be the last line or else i dont think it reads the line below the total

so do something like this

View solution in original post

mlstechwriter71
Level 2
Level 2

THAT'S IT! WOO-HOO!

Thank you for having the patience of a saint and for not giving up on this

You Sir, Completely Rock!

Thank you again!