December 6, 201411 yr I have a script of sorts, where I can add "tags" to a record, for ease of searching. The difficulty I am having is when it comes to deleting those tags. Here is my delete script: Set Variable [$TAG; Value:CaseLaw::CaseLaw_ShowTag] Freeze Window Go to Layout ["Tags" (Tags)] Enter Find Mode [] Set Field [Tags::Tags_Tag; $TAG] Perform Find [] Delete Record/Request [No dialog] Enter Browse Mode [] Go to Layout ["CaseLaw" (CaseLaw)] Set Field [CaseLaw::CaseLaw_ShowTag; ""] Go to Field [CaseLaw::CaseLaw_ShowTag] Refresh Window The problem is, lets say I have a tag that is: "criminal negligence" and then another that is simply "criminal". Let's say I want to delete the criminal tag. So I select the "criminal" tag and then run the delete script. It will INSTEAD delete the "criminal negligence" tag. What am I doing wrong that it does this? I also have a similar difficulty when I am adding the tag, in that I have it check for duplications. If I try adding "criminal negligence" first then adding a "criminal" tag second, it will say it's already been added. My script is below: Set Variable [$TAG; Value:CaseLaw::CaseLaw_ShowTag] Freeze Window Go to Layout ["Tags" (Tags)] Enter Find Mode [] Set Field [Tags::Tags_Tag; $TAG] Perform Find [] If [Get (FoundCount) ≠0] Show Custom Dialog ["NOTICE";"this has been entered before, etc"] Else New Record/Request Set Field [Tags::Tags_Tag; $TAG] End If It is driving me rather mad, I simply can't figure out what I have done wrong.
December 6, 201411 yr After the find, you basically delete the very first record found. You probably should explicitly check if that record is indeed the tag that you want. Also, change this: Set Field [Tags::Tags_Tag; $TAG] to Set Field [Tags::Tags_Tag; "==" & $TAG] using "==" forces filemaker to search for EXACT matches. The regular find in FM does a CONTAINS search. So searching for "criminal" will find - criminal - criminal investigations - criminalabcdefgh
December 6, 201411 yr I also have a similar difficulty when I am adding the tag, in that I have it check for duplications Same problem as in your first script, which Wim has already explained. But you can check for existing values without even leaving the layout: Set Variable [ $TAG; Value:CaseLaw::CaseLaw_ShowTag ] # If [ not IsEmpty ( FilterValues ( $TAG ; List ( Tags::Tags_Tag ) ) ) ] Show Custom Dialog ["NOTICE";"this has been entered before, etc"] Exit Script End If # Go to Layout ["Tags" (Tags) ] New Record/Request Set Field [Tags::Tags_Tag; $TAG]
Create an account or sign in to comment