Jump to content
Sign in to follow this  
wvdb

I'm stuck and out of time

Recommended Posts

I need to auto check a 2008 Holiday Card check box based on a found set. I also don't want to update any in the found set which may already have this box checked.

I've tried to use a loop with set field where the calculated value equals the current field & "2008 Holiday Cards" however this isn't working and I'm worried it may add the value to records that are already checked.

Any ideas?

Thanks

Share this post


Link to post
Share on other sites

I don't understand why you can't recheck a checkbox? Who'll know? How is it bad?

Share this post


Link to post
Share on other sites

I think I should be able to avoid updateding records that have already been checked by adding a 2nd request to omit these during the find, but I'm still stuck on checking the box by script.

Share this post


Link to post
Share on other sites

I didn't want to add a duplicate string of text in the list for 1000s of records. I wasn't sure how FM would handle having multiples like that.

Share this post


Link to post
Share on other sites

I got it to work. It needed a CR added in front of the "2008 Holiday Cards" string.

I would still like to know what happens if I add a value multiple times using set field. Is it safe to do this?

Share this post


Link to post
Share on other sites

Well, you will have to uncheck the box twice, if you want to remove the double value. I don't know what else you intend to do with this field, so I cannot tell what other repercussions it might have.

Why don't you constrain the found set before adding the value, or use a calculated result, e.g.

Checkbox & Case ( IsEmpty ( FilterValues ( "NewValue" ; Checkbox ) ) ; "¶NewValue" )

Share this post


Link to post
Share on other sites

A field formatted as a checkbox contains a return-separated value for each value checked, ie., multi-line. There are various ways to handle the result.

One is to use a global field, put a value in it, then use a self-relationship to the checkbox field to test for a match. This automatically only matches entire lines, so will not have false positives.

Alternatively you can use the PatternCount() function to test, in a Loop. But that will match the pattern anywhere in a line. So it depends what the value is whether that is going to be safe enough or not. The safest way to match is to add returns to both the field, and the value. Then it will only match entire lines, and it will not matter if it is the first or last line.

PatternCount ( ¶ & checkbox & ¶; ¶ & value & ¶ )

Or, as you say, omit them first. Though this would also depend on whether the Find result could have false positives. In your case, I doubt it ("2008 Holiday Cards").

But if you just set the field to itself & ¶ & value, then you could end up with the value in there twice, as 2 separate lines. It would only show in the checkboxes once. But it is kind of weird. (As comment said, especially when clearing the value.)

Edited by Guest

Share this post


Link to post
Share on other sites

Thanks for the help. I did the omit first and it worked with no duplicate values that I could see in an export of the field.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.