Expand my Community achievements bar.

SOLVED

If Then visible from value of another cell - syntax help

Avatar

Former Community Member

My form is saved as dynamic PDF, table is a set number of rows, have opted in the case of this form not to have expandable rows.  Am trying to simulate the index number of column 1 based on whether column 2 cell on same row is empty or not.  If a value is entered in 2nd cell, I am hoping to display the default value of 1st column per row.  Here is where I'm at so far, but no luck.  Not sure which event to place it.  Right now, it is in the change event of a read only cell in 1st column.  Have also tried formcalc, but had no luck there, either.  Is there a better way to simulate an index when the table is static?  Thank you!

Read Only Column
This column - empty or with value should trigger left column to show or not




SPO.sfrmBOM.Table1.Row1[0].Cell1::change - (JavaScript, client)

if (SPO.sfrmBOM.Table1.Row1.Cell2.rawValue == null  || SPO.sfrmBOM.Table1.Row1.Cell2.rawValue.length = 0)

  this.presence = "hidden";

else

  this.presence = "visible";

endif

1 Accepted Solution

Avatar

Correct answer by
Level 7

You could do something like (in formcalc in the exit event of Cell2):

if ($.isNull) then

Cell1 =  ""

else  Cell1 = "2"

endif

that way you don't have to have a default value and have it hidden originally, just leave it blank at the beginning.

View solution in original post

10 Replies

Avatar

Level 5

When i see ur script i found this mistake in your Script "SPO.sfrmBOM.Table1.Row1.Cell2.rawValue.length = 0"  should be "SPO.sfrmBOM.Table1.Row1.Cell2.rawValue.length == 0".

im nt sure whether it is causing the problem.

Vjay

Avatar

Former Community Member

Thank you, have corrected the ==, but it's still not doing anything.  Am thinking my logic is nor looking at this right, not sure how to accomplish.  I was putting the code in a numeric field, trying to 'hide' the default text value of a read only column to the left, but no luck yet.  Have also been researching how to change the color of the text based on whether numeric field is blank but not having any success trying that, either.  Any ideas welcome, thank you.

Avatar

Level 7

You have the script in the wrong event because cell1 is not actually changing until you run the script. Try putting a script into the exit event of Cell2 and you could just put something like this (in formcalc):

if ($.isNull) then

Cell1.presence = "hidden"

else Cell1.presence = "visible"

endif

Avatar

Former Community Member

Getting much closer, thank you!  It is hiding cell1 on the exit event, but that is regardless of whether I enter a value or not.  Right now I've got it in the 1st and 2nd rows in the QTY column.  Per screenshot, the Item No is still hidden, whether I delete or add a value in QTY.  Once this is working right, all items no's need to be hidden when form first opens, and then, as they enter an new line item, beginning with quanity, the item no default value should appear.  Thank you so much for your help.

1-29-2013 3-40-47 PM.png

Avatar

Level 7

so are the numbers already in the first column or do they need to be put there dynamically?

Avatar

Former Community Member

They are there as the default (row 1 default =2, row 2 = 2, etc.), but if it is better to leave them blank and dynamically add it, that would be great. I have managed to do that with expandable tables thanks to great examples found here, but was not able to transfer same idea to this static table.  I am totally open to any solution that works, thank you!

Avatar

Correct answer by
Level 7

You could do something like (in formcalc in the exit event of Cell2):

if ($.isNull) then

Cell1 =  ""

else  Cell1 = "2"

endif

that way you don't have to have a default value and have it hidden originally, just leave it blank at the beginning.

Avatar

Level 7

also to change the colour of the text just add to your if statement:

Cell1.font.fill.color.value = "13,254,123"

changing the numbers to the colour you want.

Avatar

Former Community Member

Perfect, thank you!  That was it.  I was making it way too hard!  Thanks.

Avatar

Former Community Member

Thank you for the cell color syntax, too, that will come in handy, for sure.