Search Results for 'script'
-
Search Results
-
Over on the main forum is a topic about move records from one form to another which I was curious about being able to solve.
This gives the user a list of forms excluding the currently selected one, checks to see if at least each of the fields in the source record are available in the destination and then creates a new record. In my limited testing it seems to work properly though by design it only copies records, it doesn’t delete the original so you need to do that after verification (trust, but verify).
I went through and put some comments in it that will hopefully make sense. There are two functions: the
copyHandleris a callback that does the heavy lifting and theCopy_Record_To_Formfunction sets up the initial form list and prompter.// Handler for prompter callback var copyHandler = function() { // Validate that we got a form name passed in. if (typeof formName == 'undefined' || formName.trim() == '') { console.log('Empty or undefined formName sent, cancelling.'); return; } // Mapping of source field to target field // - the key will be source field and the value will be target field. var fieldMap = {}; // List of fields in the source form that weren't found in the target form. var missingFields = []; // We shouldn't be here but let's check again. if (form.name == formName) { Utils.alertWithMessage('Unable to copy record to self', 'Please use the duplicate button to create a new record in the same form'); return; } // Get the target form. var target = document.getFormNamed(formName); // Get the source fields. var sourceFields = form.getFields(); // Iterate through each of them. for (sourceId in sourceFields) { // Look for a target field with the same name as the source field. var targetField = target.getFieldNamed(sourceFields[sourceId].name); if (targetField == null) { // If a targetField is missing, add the source field to the missing field list. missingFields.push(sourceFields[sourceId].name); } else { // Map the source field ID to the target field ID. fieldMap[sourceFields[sourceId].getID()] = targetField.getID(); } } // If we had any missing fields. if (missingFields.length) { // Prompt a message with the missing fields and let the user know it's aborted. var fullMessage = ["The following fields weren't found in the target form:", "", ...missingFields]; Utils.alertWithMessage('Copy Aborted!', fullMessage.join("\n")); return; } // Create the record data object and start to iterate through the field map. var recordData = {}; for (sourceFieldId in fieldMap) { // Set in the record data the field ID of the target field as the key // and then get the current value of the source field. recordData[fieldMap[sourceFieldId]] = record.getFieldValue(sourceFieldId); } // Don't know if this works, set a secret value to the original record URL for linking. recordData['copy-source'] = record.getUrl(); // Add a new record to the target form. var targetRecord = target.addNewRecord(); // Set the field values for the newly created record. targetRecord.setFieldValues(recordData); // Save the data and log some values for reference. document.saveAllChanges(); console.log('Original URL: ' + record.getUrl()); console.log('Destination URL: ' + targetRecord.getUrl()); } function Copy_Record_To_Form() { // Get all of the forms. var forms = document.getForms(); // A place to store a list of form names for the prompter. var formNames = []; // Iterate through all of the forms. for(var formId in forms) { // Ignore the currently selected form from the list. if (forms[formId].name == form.name) { continue; } // Append this form name to the list of form names for the prompter. formNames.push(forms[formId].name); } // Create a new prompter anddisplay the form list. var formPrompter = Prompter.new(); formPrompter.cancelButtonTitle = 'Cancel'; formPrompter.continueButtonTitle = 'Copy record'; formPrompter.addParameter('Destination Form: ', 'formName', 'popup', formNames) .show('Select form to copy record: ', copyHandler); } Copy_Record_To_Form();Topic: To script or not to script
Let’s begin with I know ZERO about scripts but it looks like a script would be the most effective way to do something I want to do. I have a database of sold houses, simple enough. I need to find a way to get the average price of a home from the “selling price” field in my database. Is a script the best bet or ???? Newbie, total Newbie and as I said, I know nothing about scripts.
Hello,
I am looking at options for an inventory system for my personal business. It has grown past the point of convenient bookkeeping with a spreadsheet. The main issue I face is that I have a bunch of different products with technical specifications I like to list out in the inventory list, and then specific instances of each of these products that have unique serial numbers. It seems pretty easy to add any number of descriptive fields to a product listing, but serial number tracking seems less obvious. To be clear, I am not looking for a hand-out or built-it-for-me template. I am happy to do the hard work of learning the software and building the database I need. But before I head down that long path I want to know if Tapforms can even do what I’m trying to do.I tested out FileMaker, it has an inventory Quickstart template that does what I want right out of the gate. But I found even basic customization of the template they provide to be very unintuitive, so while filmmaker remains a possibility I am looking for other options first.
So the main function I am looking for is to be able to define “Product A” with all its technical specifications, then define one or more “instances” of “Product A” each with a unique serial number. Each instance of “Product A” would be calculated (simple count function) to provide an inventory overview- without having to re-list each instance of “Product A” as if it were a separate product.
Ideally I would then be able to list given instances (by serial number) as sold, at which point there would be some basic sales record info attached to that instance and that instance would be removed from the inventory count for that product.
So again, not looking for a cut and paste solution, but is this a system I can build with tapforms or is it not the right software for the job?
Thanks,
sTopic: Script writing environment
OK, I’m interested in writing scripts but have no Javascript experience. Further, I don’t have a Mac, only iPhones/iPods to write and debug the scripts. Is it feasible to learn to write scripts this way? Are there additional tools available for iPhone/iPod which would help? Any other options? Or should I buy a Mac?
I have made a few brief attempts at using some of the included script fragments in Tap Forms and was able to retrieve field codes but couldn’t use those to retrieve the value of a record. The experience suggested to me that I may need a better environment to write and debug the script… among other things.
Thanks in advance!