October 8, 200718 yr Hi Guys, The following is the message I first posted on the Café. The response I received is shown as “ErrorScript” and the person said [color:red]“I am sure others will chime in on this, but here is my fellow novice opinion.” No one else chimed in so I don’t know if that means, this is the way to go or not. I just thought if you guys took a look I at least have a confirmation. My Question: There are five fields that the customer must enter information to continue. If they have not entered into all 5 fields, they get a message saying they cannot continue until the fields are entered and each of the non-entered fields are listed. I need this message to be in a field, not a dialog box. The Answer: ErrorScript: If[Customers::City ≠ "" and Customers::State ≠ "" and Customers::Zip ≠""] Set Variable [$CustomerID; Value:Customers::CustomerID] Go to Layout ["Invoice" (Invoice Table)] New Record/Request Set Field [invoice::CustomerID; $CustomerID] Else Set Field [Customers::ErrorField; "Please Complete the Following Fields: "& Let ( [Test1 = If (Customers::City = ""; "City"; ""); Test2 = If (Customers::State = ""; "State"; ""); Test3 = If (Customers::Zip = ""; "Zip"; "")]; Test1 & Case (Test1="" and Test2 ≠ ""; Test2; Test1 ≠ "" and Test2 ≠ ""; ", "&Test2; Test1 ≠ "" and Test2 = ""; "") & Case (Test1 = "" and Test2 = "" and Test3 = "";", " & Test3; Test1 = "" and Test2 ="" and Test3 ≠ ""; Test3; (Test1 ≠ "" or Test2 ≠ "") and Test3 ≠ ""; ", " & Test3; Test3=""; "")) End If The above works and I now need to know how to add 13 more fields. The If statement is clear and I added the fields with no problem. But the Set Field after the Else statement is a whole other story. My main question is, is the above a good way to handle this? Thank you very much, Milo
October 9, 200718 yr Customers::City ≠ "" Not the best way to check if a field is empty. Instead, use the IsEmpty() function. Before checking for field data I usually strip out leading and trailing white space (spaces, paragraphs). The Trim4 custom function is ideal for this. It's on Brian Dunning's site. IsEmpty( Trim4( fieldname ) ) To check if a field is NOT empty use not IsEmpty( Trim4( fieldname ) )
October 9, 200718 yr Author Hi Vaughan, Maybe you could help me with one more thing. I’ve been trying to figure out how to add to the Set Field after the Else statement. I have fields I need to add and I cannot figure out how to do it. The If statement was easy enough to figure out but I can’t understand all of the “Test and Case”. Could you show me how to add another field? I have another 13 fields to add and absolutely no idea how to do it. Thank you, Milo
October 9, 200718 yr I'm not sure it's the best way, wouldn't it be better only to regard the fields actually present on a layout, no matter how many it holds? The script as it is in the attached template needs to be broken out in subscripts, but the only way to get what it's about is to trace it via the second from left button in the debugger, due the numerous recusions, but recusions are chosen for it's stacking of paramters, instead of making a long string of parameters delimited via say ¶... --sd igotit.zip
October 9, 200718 yr Author Hi Soren, Hey thanks for the file. It sure helps to be able to see what to do in real time. This is a solution that will be on the web so I can't use a pop up message; it has to be in a field. How would you change the scripts so the message is shown in a field and separated by a carriage return? Milo
October 9, 200718 yr If you take a look - I kind of knew you might be IWP'ing, hence the gathering of the message in an invisible global field before flashing it, you could have it in a different invisible tab, as log as it's pulled out of the cursors taborder: http://www.databasepros.com/FMPro?-DB=resources.fp5&-lay=cgi&-format=list.html&-FIND=+&resource_id=DBPros000816 ...although it isn't a differnt sortorder of the same data here, is it the same tecnique to make the tabs invisible. --sd
October 10, 200718 yr Author Hi Soren, I Read and reread and then rereread your post. I opened the file, scratched my head, closed the file, ran some ice cold water over my face, reopened the file again, read the information, looked at what was happening, went back to the kitchen, added some Scotch to that cold water and realized anew how much fun you FileMaker guys can really be! I even went back over my posts thinking "Hey maybe I said something to make Soren think I had a clue. But I realized very quickly that wasn’t it. So it could only come down to one thing. That Ol Soren is really having fun with Ol Milo. Now if you're through gloating over having a good time at the expense of the Wyoming Boy, what should I really do? Milo
October 10, 200718 yr It seems to me the "Test & Case" portion is just trying to construct a semicolon separated list of the empty field's display names. Here's an example file showing an alternative way using a custom function to build up a list of empty field's name's. The important part is the custom function: EmptyFields( fieldNmes; accum ) = If ( IsEmpty(fieldNmes); accum; Let( [ firstFieldName = GetValue(fieldNmes;1); restNames = RightValues( fieldNmes; ValueCount(fieldNmes) - 1 ); fieldIsEmpty = not IsEmpty(firstFieldName) and IsEmpty(GetField(firstFieldName)) ]; EmptyFields( restNames; accum & If ( fieldIsEmpty; If (not IsEmpty(accum); ¶) & firstFieldName) ) ) ) testNCase.fp7.zip
October 10, 200718 yr Cool, but in order to get almost total independence in deployment which was my objective - could this be used instead of the hardwired: Let(tt=FieldNames ( Get ( FileName ) ; Get ( LayoutName ) );Substitute ( tt ; ["¶message" ; "¶"];["¶¶";"¶"] )) ...leaving the fieldname "message" a reserved word, which can't be part of any of the other fieldnames. --sd
October 10, 200718 yr I don't think you can avoid referencing the watched fields explicitly in the calculation, if you want it to re-evaluate when one of the fields is modified.
October 10, 200718 yr I saw it Michael, and turned the calc' unstored ...it seems to work. But it favours perhaps the scripted method then?? My agenda is to an as portable algorithm as posible! what should I really do? If IWP'ing is the main thing here, would I ditch the "reporting" or "messageing" and instead provide the interface itself with some signaling! Take a look! (good grief I'm flagging - hardly an embraced scripting style!) The scripting might seem a little clunky, but: http://www.filemaker.com/help/Script-Steps36.html isn't web-compatible!!! --sd HowIwouldIWP.zip
October 10, 200718 yr I saw it Michael, and turned the calc' unstored ...it seems to work. I don't think so. If you fill/clear a watched field, you need to click into the calculation field or use another method to force a refresh.
October 10, 200718 yr Meanwhile did I come up with this weird fm9 only idea... --sd ConditionallyIWP.zip
October 10, 200718 yr Author Hi Guys, Of everything I've seen it looks like the "HowIwouldIWP.fp7" solution is the easiest to implement and I really like that the error is shown in the actual field instead of a list of fields. I added a new field and boom, it was right there included in the list. My question is, what if you have a field or two on the layout that is not a "Must Enter" field. How do you exclude these fields from the search? One other thing I just noticed and that is we need to keep them from going to the next layout until all required fields are filled in. You guys are great by the way. Milo Edited October 10, 200718 yr by Guest
October 10, 200718 yr Fire the script in another layout where the fields are excluded and then turn back to the layout you wish the user to see! --sd
October 10, 200718 yr It may seem easy to implement, but watch what happens when the field is date or time.
October 10, 200718 yr Author Hello again, Comment, I don’t think date and time fields would come into play on this layout so that should not be a problem Soren Said: Fire the script in another layout where the fields are excluded and then turn back to the layout you wish the user to see! I don’t follow. We’re on the Customer Setup layout that has 10 must enter fields and 3 optional fields. I don’t understand how going back and forth to anther layout would handle the "Must enter fields from the Optional fields and wouldn't that be very confusing to the customer? Or are you talking about "going to the next layout after all required fields are filled in"? Milo
October 10, 200718 yr Initiate the script by going to a duped layout excluding the 3 fields, in the end of the script return to the layout the user have put his/her info in and watch the asterixes havn't found their way into the "Optionals" - take a look: --sd HowIwouldIWP2.zip
October 10, 200718 yr I don’t think date and time fields would come into play on this layout so that should not be a problem That's what they said about Y2K too...
October 10, 200718 yr Author This is so COOL I can hardly stand it. Where do you guys come up with this stuff? I just need your help on two things. When a Must Enter field is missed and you get the [color:red]......................, when you enter infromation it stays [color:red]RED. How do I get it back to Black? The other thing is once everything is entered correctly, how do I get to the next layout called "Business Page"? Milo
October 11, 200718 yr I saw it comming and began the next template with conditional formatting, however can something be done! You could prepend the asterix'es with ... in the default font and then followed by the colored ones. But please explore the "condtional formatting" it seems a more obvious path!! --sd
October 11, 200718 yr Author Hi Soren, What I did is just changed the ******* from red to Black and that solved the whole problem. Not as elegant as the red, but it works. One last question. I have the following script that I would like to add to your Mandatory script. How do I add it so it triggers only after the other conditions are met? Set Variable [ $id; Value:Customers::ContactID ] #Go to the invoice layout Go to Layout [ “Customer Entry” (Invoices) ] #Make the invoice New Record/Request #Push the contact ID from the variable Set Field [ Invoices::ContactId; $id ] # Commit Records/Requests [ Skip data entry validation; No dialog ] Thanks Soren, Milo
October 15, 200718 yr I was going to suggest that your button simply set a field to 1 to toggle the formatting on and off; the fields would all have the conditional formatting formula: IsEmpty(Self) and testNCase::evaluated = 1 This works great to set the fill color of the empty fields. Unfortunately conditional formatting doesn't work in IWP. ;)
October 25, 200718 yr Author Hi Soren, If you look at post #269382 it shows a “Make Invoice” script that captures an ID# from the Customer TO and takes that same ID# and creates a new invoice in the Invoice TO. This script works perfectly if you run it by itself from the Customer TO. Here’s the problem. This script is called from within another script shown on post #269546 showing where the above script was placed. That’s where I put it and it does go to the right layout in the Invoice TO but it does not make a new record. What do I have to do to get the script to work correctly. Milo
October 26, 200718 yr This must be a layout wich reside in a different TOG where the setting of: Set Variable [ $id; Value:Customers::ContactI D ] ..not quite makes sence, what does the Dataviewer tell you when you trace it with the debugger? Another thing it could be is if you have several files in your solution, variables does only live until the boundaries of each file it's defined in, to solve this use script-parameters/result instead! --sd
October 30, 200718 yr Author Hi Soren, Another thing it could be is if you have several files in your solution, variables does only live until the boundaries of each file it's defined in, to solve this use script-parameters/result instead! I'm not exactly sure what you mean. Could you show me based on the script shown on post #269546 above? Milo
October 30, 200718 yr No! Really - I need to see the file(s) before making a proper judgement ... it should be straight forward but what you unintended have kept out of the equation - is pretty hard to guess! However do you in the thread: http://fmforums.com/forum/showtopic.php?tid/190966/post/271080/#271080 ...talk about the separation model, which means several files in plural ... this is an obvious limitation of the $variables scope! --sd
October 30, 200718 yr Author Hi Soren, As I said earlier, if I run the “Make Invoice” by itself it works perfectly. It just does not work when added to this script. It looks from what you’ve said that the problem may be in the “$variables”. Is there another way to do it by replacing the “$variables” with something else? Milo
October 30, 200718 yr Author Hi Soren, Thanks for the link, but I have no idea what the information is telling me. Milo
October 30, 200718 yr Variables arrived with fm8 or fm8.5 before that were other means chosen, script-paramters arrived with fm7 ... before that was yikes! global fields used. But couldn't you let us poke into your stuff to establish the reason why the variable doesn't work? Why do you use a $variable and how does it get it's value, well the script kind of say it, but what we can't see is if you attepts to transfere it's value to a new file. --sd
October 30, 200718 yr "As I said earlier, if I run the “Make Invoice” by itself it works perfectly. It just does not work when added to this script. It looks from what you’ve said that the problem may be in the “$variables”. Is there another way to do it by replacing the “$variables” with something else?" Normal $variables only work within the script in which they are created. This could be the problem. To pass values between scripts in the same file, use global $$variables. To pass values between scripts in different files, use either script parameters or store the values in global field and access them via a relationship.
October 31, 200718 yr Author Hi Vaughan, We’re using the separation model as you know and the script runs between two TO’s Contacts and Invoices. Both you and Soren make excellent points, my only problem is having any idea what those points are! Could you tell me how I would change the above script to accomplish what we’re all talking about? Thanks guys and one day I’ll understand all this stuff and be known as the “Ayatollah-of-Rock-n’ Rolla”. Milo
October 31, 200718 yr #Go to the invoice layout Go to Layout [ “Customer Entry” (Invoices) ] #Make the invoice New Record/Request #Push the contact ID from the variable Set Field [ Invoices::ContactId; Get(Scriptparamter) ] # Commit Records/Requests [ Skip data entry validation; No dialog ] Where the contact ID is the scriptparamter! But you can even sophisticate it a bit more by using the script parameter in the autoenter when the record is made, this will let omit the set field step... --sd Igotit2.zip
October 31, 200718 yr Author Hi Soren, I changed the script as shown above, but again, it goes to Invoices and creates a new record but the ID number in the contacts is not recoreded in the Invoices file. Milo
October 31, 200718 yr You need to set the option field (parameter) in the Perform Script dialog for the line i marked in the red in the calling script, to the ID you wish to transfere. --sd
October 31, 200718 yr Author Hi Soren, Yes sir that sure did it. Thank you so much for your help. Milo
October 31, 200718 yr Author Hi Soren, First I feel I must appologize for the amount of time we've spent on this one script, but I'm sorry to report I'm still in trouble. Now the ID number is captured and is placed on the invoice with the new record. The problem is I stay on the Contacts layout in stead of the Invoice layout. I tried some things to make it work but no luck. Milo
October 31, 200718 yr No worries, we've all been beginners once and a while ... no need to be so apologetic!! Zip your stuff an e-mail it to me off forum, and I'll try figure out what's the problem ... you'll find the details in my profile! --sd
October 31, 200718 yr Author Hi Soren, Thanks for making the offer to send my solution over to you. I'm not sure I know how to break it up to accomplish it and thought maybe I could try this one more time. Let me show you how the scripts are set up. On the script you made for me above "Post#269546" it is called from my Contacts layout in the Contacts TO. I added the following at the bottome of the script just after your, Go to Layout (Original layout) If [ Contacts::NumbergTest1 + Contacts::NumberTest2 = Contacts::NumberTestAnswer ] Clear [ Contacts::NumberTestAnswer ] [ Select ] Go to Layout [ “Invoices-Enter Invoice” (Invoice_Entry) ] End If I can tell from the way the script performs that where I've added this presents a problem. I simply don't know where to put it. The Perform script "Make Invoice" in your script "Post#269546" is exactly as shown in your Post#271239. Can you see from this what I've messed up and what can be done to correct it? Milo Edited October 31, 200718 yr by Guest
November 1, 200718 yr Go to Layout (Original layout) The above could be hardwired to a specific layout, instead... If [ Contacts::NumbergTest1 + Contacts::NumberTest2 = Contacts::NumberTestAnswe r ] Clear [ Contacts::NumberTestAnswe r ] [ Select ] Waht are you doing here?? You're adding two fields and compare them with a third, why?? --sd
November 1, 200718 yr Author Hi Soren, The last field on our sign up layout is "NumberTestAnswer" where two random numbers are shown and here you give the answer. So it would be something like: "NumberTest1" is [color:blue]3 and "NumberTest2" is [color:blue]4 you must put [color:blue]7 in the "NumberTestAnswer" field to continue. Since this is the button you click to check that selected fields are not empty and move on to the Invoice layout. I thought this is where it would go. I guess I was wrong hu! Milo
November 1, 200718 yr Ah it's some kind of hacker prevention, you pull up two blured images of two numbers, and if the user can't watch the images and by it do the (math) are the entire validation brought to an end??? --sd
November 1, 200718 yr Author Hi Soren, Yes, it's just like the validation you put in place for the "Must Enter Fields". If you don't answer the math question correctly you cannot leave the sign up page. Now how do we put the whole thing together? Milo
November 2, 200718 yr Since I already have been naughty and used a $flag variable, could you just put the extra condition in before the calling of the "Make Invoice" script, it's done in a few lines ... if the math doesn't add up set $flag=0 --sd
November 2, 200718 yr Author Hi Soren and Top of the Morning to You, I'm not sure what you want me to do. Is this how you want the script to read. Exit Loop If End Loop If [$flag] [$flag=0] Perform Script ["Make Invoice"] Milo
November 2, 200718 yr Not quite, try instead this: .... Exit Loop If End Loop If [ Contacts::NumbergTest1 + Contacts::NumberTest2 ≠ Contacts::NumberTestAnswe r] Set Variable [ $flag; Value:0 ] End if If[$flag] Perform Script ["Make Invoice"] Else .... ...remember the scriptparameter! --sd
Create an account or sign in to comment