Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using If and getselectedcount

I have a text object that I would like to display "Test" if there are selections made for the CostCenterCode with

getselectedcount(CostCenterCode).  Otherwise, display "Space."  I created the expression below and put it into the Text area of the Text Object.  I am not getting just the Test or Display.  I get a text with the code that I wrote.  I have researched but have not found anything to resolve this issue.  I hope you can help.

if(getselectedcount(CostCenterCode)<1, 'Test', 'Space');

1 Solution

Accepted Solutions
trdandamudi
Master II
Master II

You need to remove the semi colon at the end:

=if(getselectedcount(CostCenterCode)<1, 'Test', 'Space')

View solution in original post

8 Replies
trdandamudi
Master II
Master II

Try putting a equal (=) in the front:

=if(getselectedcount(CostCenterCode)<1, 'Test', 'Space')

Note: Also remove the colon at the end.

Anonymous
Not applicable
Author

I got an error message if I do that,

trdandamudi
Master II
Master II

You need to remove the semi colon at the end:

=if(getselectedcount(CostCenterCode)<1, 'Test', 'Space')

Anonymous
Not applicable
Author

Anonymous
Not applicable
Author

Then you want

=if(getselectedcount(CostCenterCode)>0,'Test','Space')

The way you have it written now is less than 1.

Anonymous
Not applicable
Author

trdandamudi
Master II
Master II

Then you need to re-write the code as below:

=if(getselectedcount(CostCenterCode) > 0, 'Test', 'Space')

Anonymous
Not applicable
Author

It's because CostCenterCode and CostCenterName are 2 difference fields.  If you want to check both you could do something like

=if(getselectedcount(CostCenterName)+getselectedcount(CostCenterCode)>0,'Test','Space')