sternopygus Posted February 13, 2003 Posted February 13, 2003 Is there a way to -edit multiple records using CDML. Situation - I Perform a search Now I would like to get a specific value "12345" into the 'Field:ID' for all of those records returned by search. thanks kevin
Addam Posted February 13, 2003 Posted February 13, 2003 Hi there! Check out this Topic posted about a month and some change ago. I put up examples & a logical explination towards the end for other ways of doing this. http://www.fmforums.com/threads/favlinker.php?Cat=&Entry=340&F_Board=UBB22&Thread=50560&partnumber=&postmarker= Let me know if you have any questions. ~Addam~
sternopygus Posted February 13, 2003 Author Posted February 13, 2003 O.K. I checked out those explanations, and even tried the javascript code, but it didn't work. I couldn't understand your explanation in the last part titled "After digging, I've come up with the proper way of doing this..." I've been using CDML for quite some time, but I don't know much about javascript. Maybe you could show me what the code might look like. Here is my situation: 1) I have performed a search 2) Now I am at the search results page 3) Each record is a seperate form, where I have included <input type="text" name="EmailMessage_code" value="[FMP-CurrentToken:4]"> <input type="hidden" name="-edit"> etc... now I just want to click a 'link' or 'submit button' and have it edit all those records with the value of -token.4 help is much appreciated thanks
Addam Posted February 13, 2003 Posted February 13, 2003 I see what you are trying to do. But your missing some logic there. There is no need for tokens in this operation. However, JavaScript plays is what brings this all together. It is Very Complicated, but once you've got it, it will work like a charm. Basically, you want to submit all of the forms/records all at once with a click of a button right!? If so, here is how you do it. On the Parent Document, create a form anywhere in the document that looks like this: <form name="count"> <input type="hidden" name="times" value="0"> </form> All this will do is store values. Nothing else. Now, the forms that repeat should have the "-format" value set to "done.html". ..Create a variable on the parent document (doc. with all the forms) and call it "processed". The Value of this variable should be set to "0". Now you need to set another variable that contains a CDML Value. This will give JavaScript a handle to how many records are being presented. Ex: var processed = 0; Ex: var rangeSize = [FMP-RangeSize]; ..Create a function on the parent document that is called "completed". This function has 1 main purpose in life and that is to refresh the HTML page to either a new location or the same location with the new data in it. Ex: window.location = "[FMP-Link: sa]&-format=users.html&-Find"; ..Create a Blank HTML page that is called "done.html". In the head of this document, you will need to put a JavaScript command that will pass the value "1" to a function on the parent document whenever it gets loaded. ..Create a function on the parent document to capture the variable being set by the "done.html" document. Now, inside this function you will need to tell JavaScript to take the current value of "times"(on the form) and add it to itself, then reset the new value to the "times" field on the form. // This is so we can keep track of how many forms have already been processed. ..Within this same function you need to put in an "If" statement in there that say's "If the "times" field equals the "rangeSize" variable, then run the function "completed". // In a nut shell we are telling JavaScript to reload the page once all of the forms have been processed. Ok... Now lets get into the actual forms... Your forms should look something like this: [FMP-Record] <form action="FMPro" method="post" name="editForm[FMP-CurrentRecId]" target="frame[FMP-CurrentRecId]"> <input type="hidden" name="-DB" value="[FMP-CurrentDatabase]"> <input type="hidden" name="-format" value="done.html"> <input type="hidden" name="-RecID" value="[FMP-CurrentRecId]"> <input type="text" name="email" value="[FMP-Field: email]"> <input type="text" name="EndUser" value="[FMP-Field: EndUser]"> <input type="text" name="Extension" value="[FMP-Field: Extension]"> <input type="hidden" name="-edit"> <iframe name="frame[FMP-CurrentRecId]" id="frame[FMP-CurrentRecId]" height="0" width="0"> </iframe> </form> [/FMP-Record] Now to keep the forms & iframes unique, we use the form name (editForm) and the "RecId" of each record. This way they all submit into their own "<iframe>". So now that all of this is set up. The logic will now make sense in the back end. 1) present a set of records in their own form and they have iframes associated with them. 2) press submit and start processing the forms. 3) FORM - once I'm processed open the "done.html" in my iframe. 4) Completed Function - "done.html" has just passed me "1". Now add that to the value in "times" then set the new value in the same field (times). 5) Completed Function - once "times" = "rangeSize", refresh the page to a new document showing the new data. That's it! Hope this helps! ~Addam~
sternopygus Posted February 14, 2003 Author Posted February 14, 2003 O.k. thanks for all the advice. I have not doubt that javascript works great when one knows how to use it. I solved the problem of editing multiple records using a combination of CDML and internal FM scripts. The point of using that token:4, as in most cases, was simply to pass a value, it had nothing to do with trying to submit multiple records. As I have figured out many times before, if you spend enough time working with FM scripts, you will solve your problems. For anyone interested in submitting multiple records here was I did: 1) I performed my search and also passed a token (from some previous page) to the search page 2) On the search page, I submitted the token to an empty field in a dummy database, and executed a script that took the value (token) passed to the dummy database and placed it into each of the records that were still in the found set of records. Of course, we are all aware of those problems with using scripts, but if the scripts executes, and then exits fast enough, its generally not a problem. thanks
Addam Posted February 14, 2003 Posted February 14, 2003 Not Bad! I'm glad it all worked out for you. I use the JavaScript method because JavaScript is client side processing. When you have 3-400 people working on one or more databases, you don't want the server being overloaded with multiple scripts firing at the same time. You might even run into a few collisions (not good). We have about 15 projects going at the same time and each of them have about 3-5 databases attached to them. Using this method cuts down on the server load because all it's doing is processing records. In addition to that, since FMP doesn't have a "Template Design" function like Lotus Notes does where we can change a template, and it will change all databases you tell it to, this will work for all databases we create simply because the HTML page is a template. Great Job! ~Addam~
Unable Posted February 14, 2003 Posted February 14, 2003 "As I have figured out many times before, if you spend enough time working with FM scripts, you will solve your problems" Unless you create new problems. ScriptMaker handles one event at a time and does not queue event requests made when processing an event. CDML does not recognize event failures and is unable in and of itself to generate an error page to the client when an event failure occurs. How rigorously have you tested your "scripts" in a multi-user environment? Prepare yourself for a burst bubble.
Newbies Shanley Posted March 5, 2003 Newbies Posted March 5, 2003 Pardon me for being a bit of leech here, but I've really learned a lot from this thread. However my javascript skills are pretty in adequate and I haven't been able to make this work. I even tried your suggestions from last year sometime, but the refresh doesn't work. Do you have an example somewhere? - Shanley
Addam Posted March 5, 2003 Posted March 5, 2003 I can trouble shoot the refresh part. Using the method that I posted last year (minus the refresh) were the records being changed in the database? If they were then, that's good. I can post an auto refresh code up if that's what you need!? Keep me posted! ~Addam~
Recommended Posts
This topic is 8003 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now