FileMaker global list field - filemaker

I'm trying to create a multi select function by adding and removing record IDs into a global field.
I've created a global field called current_selection.
I attached a script action to the name field that is suppose to add or remove the record id to the global field.
If ( PatternCount ( committee::current_selection; committee::id & "¶"); Substitute ( committee::current_selection; committee::id &"¶"; "¶"); committee::id & "¶" &committee::current_selection)
and that is how i set the global field.
Meanwhile I set conditional formatting for the name field for a visual of what is selected
PatternCount ( committee::current_selection; committee::id & ¶)
so what happens is 1 is selected when 11 is selected then if I click 1 it takes 1 off 11
Not sure why this is happening

Well, "1" is included in "11", so your test produces a false positive. And substituting "1¶" out of "11¶" leaves "1".
To see if an item exists in a list of return-separated values, use:
IsEmpty ( FilterValues ( item ; listOfValues ) )
Removing an item from a list is more difficult than it might seem. Start with:
Substitute ( ¶ & listOfValues & ¶ ; ¶ & item & ¶ ; ¶ )
then remove the extra carriage returns from the result.

Related

How can I create a goto expression in xtext?

I want to create a goto expression as follows
//label
<bb 2> :
//goto
goto <bb 2>;
The following grammar works fine for a simple ID. I have no idea how to reference the <ID INT>
in the goto expression.
Goto returns Goto:
{Goto}
'goto' goto+=[Label] ';'
;
LabelDef returns LabelDef:
{LabelDef}
label+= Label ':'
;
Label returns Label:
{Label}
name= ID
;
Do have any idea how to that?
the feature you are looking for is a DataType rule
Goto returns Goto:
{Goto}
'goto' goto+=[Label|IDandINT] ';'
;
LabelDef returns LabelDef:
{LabelDef}
label+= Label ':'
;
Label returns Label:
{Label}
name= IDandINT
;
IDandINT: ID INT;
you may also introduce / customize DefaultTerminalConverters/IValueConverter for the datatype rule to normalize whitespace
I think you want a terminal that is essentially "ID INT" and then use it to crossreference your Label.
I think this is going to be a lot of work just to be able to allow "spaces" in your labels. Why not simply rely on terminal "ID" and users may name them "bb2" if they wish?

Reason Type field in domcfg

To ensure more security to my XPages web application, I put a captcha in the custom login form in domcfg.nsf.
I followed the link to build my captcha :
http://www.notesmail.com/home.nsf/tip20100506
The problem is when log in, if the captcha is misunderstood , I can not update the value of the field to reasontype it makes me appear the message "Wrong captcha code."
I added this action to check if the text entered is equal to captcha :
#If ( #UpperCase ( MyCaptchaField ) = TheRealValueOfMyCaptcha ; FIELD reasontype: = "6" ; "")
and I added a condition that shows me an error in the calculated field error messages if the value of reasontype is equal to "6" .
This does not work and I can access my XPage even if the captcha is not written.
I feel that the reasontype field depends only 5 predefined conditions.
Is there a solution to add other conditions in log on form?
You've got a space between the colon and equal characters. That means the characters are treated as two operators - a list concatenation operator and an equality operator.
Instead of this
#If ( #UpperCase ( MyCaptchaField ) = TheRealValueOfMyCaptcha ; FIELD reasontype: = "6" ; "")
You need this:
#If ( #UpperCase ( MyCaptchaField ) = TheRealValueOfMyCaptcha ; FIELD reasontype := "6" ; "")
However, the classic style for this would be:
FIELD reasontype := #If ( #UpperCase ( MyCaptchaField ) = TheRealValueOfMyCaptcha ; "6" ; "");
You have syntax error there...This is corrected code:
#If ( #UpperCase ( MyCaptchaField ) = TheRealValueOfMyCaptcha ; FIELD reasontype := "6" ; "")
That code is for an old-style Domino web form, not XPages. An alternative would be using an XPages-specific implementation and using an AJAX login post. Here are a couple of OpenNTF I found:
https://www.openntf.org/main.nsf/project.xsp?r=project/Xpages%20Captcha%20Custom%20Control
https://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=Recaptcha%20Custom%20Control
Here is a blog post which points to another OpenNTF project by Declan Lynch with an AJAX login Custom login forms in xpages?
Here is also an XSnippet for a login custom control (doLogin is the SSJS method to log in) https://openntf.org/XSnippets.nsf/snippet.xsp?id=dojo-login-dialog-custom-control
I tried this code. But the problem is that it automatically connects to my application and ignore the validation of the captcha.
I found a solution with a redirect to the logout page in the "onsubmit" action if the captcha is wrong and it works and a web alert to avoid the reasontype field.
Thanks for your help.

FMP 14 - Auto Populate a Field based on a calculation

I am using FMP 14 and would like to auto-populate field A based on the following calulation:
If ( Get ( ActiveLayoutObjectName ) = "tab_Visits_v1" ; "1st" ) or
If ( Get ( ActiveLayoutObjectName ) = "tab_Visits_v2" ; "2nd" ) or
If ( Get ( ActiveLayoutObjectName ) = "tab_Visits_v3" ; "3rd" ) or
If ( Get ( ActiveLayoutObjectName ) = "tab_Visits_v4" ; "4th" ) or
If ( Get ( ActiveLayoutObjectName ) = "tab_Visits_v5" ; "5th" ) or
If ( Get ( ActiveLayoutObjectName ) = "tab_Visits_v6" ; "6th" )
The above code is supposed to auto-populate the value 1st, 2nd, 3rd ... in field A depending on the name of the object the Get (ActiveLayoutObjectName) function returns. I have named each of my tabs, but the calculation is only returning 0.
Any help would be appreciated.
thanks.
The way your calculation is written makes very little sense. Each one of the If() statements returns a result of either "1st", "2nd", etc. or nothing (an empty string). You are then applying or to all these results. Since only of them can be true, your calculation is essentially doing something like:
"" or "2nd" or "" or "" or "" or ""
which happens to return 1 (true), but has no useful meaning.
You should be using the Case() function here:
Case (
Get ( ActiveLayoutObjectName ) = "tab_Visits_v1" ; "1st" ;
Get ( ActiveLayoutObjectName ) = "tab_Visits_v2" ; "2nd" ;
Get ( ActiveLayoutObjectName ) = "tab_Visits_v3" ; "3rd" ;
Get ( ActiveLayoutObjectName ) = "tab_Visits_v4" ; "4th" ;
Get ( ActiveLayoutObjectName ) = "tab_Visits_v5" ; "5th" ;
Get ( ActiveLayoutObjectName ) = "tab_Visits_v6" ; "6th"
)
Note also that a calculation field may not always refresh itself as a result of user switching a tab. This refers to an unstored calculation field; if you are trying to use this as the formula to be auto-entered into a "regular' (e.g. Text) field, it will never update.
Added:
Here is our situation. We see a patient a maximum of 6 times. We have
a tab for each one of those 6 visits.
I would suggest you use a portal to a related table of Visits instead of a tab control. A tab control is designed to display fixed components of user interface - not dynamic data. And certainly not data split into separate records. You should have only one unique record for each patient - and as many records for each patient's visits as may be necessary (potentially unlimited).
If you like, you can use the portal rows as buttons to select a specific visit to view in more detail (similar to a tab control, except that the portal shows the "tabs" as vertical rows). A one-row portal to the same Visits table, filtered by the user selection, would work very well for this purpose, I believe.
With 1. .... it would be easy:
Right (Get ( ActiveLayoutObjectName ) ; 1) & "."
Thanks for pointing out, that my first version does not work.

FileMaker Pro 12 - Using Commas As Separators For Address Export

FMP12
I need to use commas to separate data from customer addresses. The address is imported into a notes field like this: "1234 East Palm Ave, Berkeley, Ca 94150".
My script needs to recognize if the street name is 2 or 3 words, and if the city name is 1 or 2 words. The info gets broken up into a couple different Set Variables $streetName, $CityName, $ZipCode, and exported to create a new customer profile.
I was trying to do that with a string search function that finds the position of the first and second instand of each "," but my function isn't working. Any hints about which function to use would be greatly appreciated.
Assuming the formatting is consistent, try:
$streetName =
Let (
tokens = Substitute ( Address ; ", " ; ¶ )
;
GetValue ( tokens ; 1 )
)
$cityName =
Let (
tokens = Substitute ( Address ; ", " ; ¶ )
;
GetValue ( tokens ; 2 )
)
$zipCode =
RightWords ( Address ; 1 )

How do I get a list of values?

I have a table Targets with unique ID number and field data. I want to get a list containing all values of number in Targets so this list (preferably comma separated) can end up as a JS array in a Web View.
In SQL, it would be as simple as
SELECT number FROM Targets
But I can't find any reasonable method in FileMaker Pro Advanced 11. I think the List function may be it, but for some reason, it won't list all my rows.
Bonus points if you can do the equivalent of
SELECT number, data FROM Targets
On the Targets table, add a calculation field (say, ID Data Array) that looks like a javascript array literal:
"[" & number & "," & data & "]"
On a layout that has a cross-product relationship to a Targets table occurrence (say, Targets All), add a Web View component with something like the following calculated content:
"data:text/html,¶" &
"<!DOCTYPE html PUBLIC " & Quote ( "-//W3C//DTD XHTML 1.0 Strict//EN" ) & "¶" &
Quote ( "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" ) & ">¶" &
"<html xmlns=" & Quote ( "http://www.w3.org/1999/xhtml" ) & ">¶" &
"<head>¶" &
"<meta http-equiv=" & Quote ( "content-type" ) & " content=" & Quote ( "text/html; charset=utf-8" ) & " />¶" &
"<title>Table Data</title>¶" &
"<script type=" & Quote ( "text/javascript" ) & " src=" & Quote ( "script.js" ) & " ) & ">¶" &
"var dataArray = [ " & Substitute ( List ( Targets All::ID Data Array ) ; "¶" ; "," ) & "];¶" &
"</script>¶" &
"</head>¶" &
"<body>¶" &
"</body>¶" &
"</html>"
The key component is this:
"var dataArray = [ " & Substitute ( List ( Targets All::ID Data Array ) ; "¶" ; "," ) & "];¶"
This uses the List function to collate all the related ID Data Array fields into one ¶-delimited list.
It then uses the Substitute function to replace the ¶ characters with commas so you get a nice comma-delimited list of arrays.
Finally, it wraps it in a javascript variable declaration so you will have the variable dataArray available in the rest of the page.
If you're in FileMaker Pro 11, use one of the SQL plugins to query itself. Or, upgrade to v12 and use the new SQL command.
The easiest way, which may seem like a hack but is not, is to make a valuelist. Make a valuelist set to display all values in "number". FileMaker will automatically consolidate all values into a return-separated list of unique values. Then you can get the list by running the calculation:
ValueListItems( Get(FileName) ; "AND-PUT-YOUR-VALUELIST-NAME-HERE")