Search Results for 'script'
-
Search Results
-
I need to send emails to members. I have a form which contains various pieces of text I routinely send mostly when there is no phone number associated with a members information.
I’d like to include fields from the record in the email like…
Dear [firstName]
Your address is [city] [state] [zip]
Well, you get the idea.
Is there a way to do this in tapforms? Perhaps thru a calculation field or a script?
Thanks,
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.