Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nickedw0
Creator
Creator

Trigger to default Select to default value or previous selection

I use the following trigger to set a Year field selection to Variable1 if Year has no prior selection, or to its previous value. This works if only a single year is preselected. But if multiple years are selected, it fails. Any help would be appreciated.

=if(len(getFieldSelections(Year))=0,Year(Variable1),getFieldSelections(Year))

Thanks

1 Solution

Accepted Solutions
nickedw0
Creator
Creator
Author

This is close to perfect. I changed to:

=if(getselectedcount(Year)=0,Year(Variable1),'('&concat(Year,'|')&')')


Problem is each iteration adds a set of brackets, like (((2015|2016))) after 3rd time sheet is selected. or ((((((2015|2016)))))) after 6th.

View solution in original post

8 Replies
sunny_talwar

What is Variable1 here?

nickedw0
Creator
Creator
Author

Variable1 has the current date

sunny_talwar

So when multiple years are selected, then which would be the previous year? Lets say you selected 2017 and 2016, previous year will be 2015?

woshua5550
Creator III
Creator III

Try this 

=if(getselectioncount(Year)=0,Year(Variable1),'|'&concat(Year,',')&'|')

woshua5550
Creator III
Creator III

Sorry, ignore above

It would be

=if(getselectedcount(Year)=0,Year(Variable1),'('&concat(Year,'|')&')')

nickedw0
Creator
Creator
Author

This is close to perfect. I changed to:

=if(getselectedcount(Year)=0,Year(Variable1),'('&concat(Year,'|')&')')


Problem is each iteration adds a set of brackets, like (((2015|2016))) after 3rd time sheet is selected. or ((((((2015|2016)))))) after 6th.

nickedw0
Creator
Creator
Author

Ok, That was the correct answer. The extra brackets were comming from an exit trigger I forgot to remove.

woshua5550
Creator III
Creator III

Ok,you can mark my answer as correct answer if it was helpful, have a good day:)