Mapping user spreadsheet columns to database fields - coldfusion

I’m not sure where to start on this project. I know how to read the contents of the excel spreadsheet, I know how to identify the header row, I know how to loop over the contents. I believe I have the UX portion worked out but I am not sure how to process the data.
I’ve googled and only found .Net solutions but I’m looking for a ColdFusion/Lucee solution.
I have a working form allowing me to map a user's spreasheet column to my database values (this is being kept simple for this post; user does not have direct access to the database).
Now that I have my data, I'm not sure how to loop over the data results. I believe there will be several loops (an outer and an inner). Then of course I also need to loop over the file contents but I think if I can get the headings mapped out,I can figure out the remaining.
Any good links, tutorials, or guides would be greatly appreciated.
Some pseudo code might be enough to get me started.
User uploads form
System reads headers and content.
User is presented form with a list of columns from their uploaded spreadsheet to match with available database fields (eg “column1” matches “customer name”.
User submits form.
Now what?
UPDATED
Here is what the data looks like AFTER the mapping has been done in my form. The column deliiter is the ::: and within the column the ||| indicates the ID associated with the selected column value. I've included the id and the column value since I plan on displaying the mapping again as a confirmation. Having the ID saves a trip to the database.

If I understand correctly, your question is: how do you provide the user a form allowing them to map their spreadsheet columns to that of the database
Since you have their spreadsheet column names, and you have the database column names, then this problem is essentially a UI/UX problem. You need to show both lists, and allow the user to map them. I can imagine several approaches to this. My first thought would be some sort of drag/drop operation, as follows:
Create a list of boxes, one for each field in your database table, and include the field name in (or above) the box. I'll call this the db field list. Then, create another list for each column from the spreadsheet, which I'll call the spreadsheet column list. The user would drag/drop items from the spreadsheet column list to the db field list.
When a mapping has been completed by the user, you would store the column/field names in as data for the DOM element of the db field list box. Then upon submission, you would acquire the mapping data by visiting each box and adding it to an array. Then you would serialize that array into JSON and send that to your form submission handler.
This could be difficult or easy, depending on your knowledge of UI implementations using JavaScript. jQuery makes this easy (if you know jQuery). There's even a jquery UI plugin that does this: https://jqueryui.com/droppable/.
A quick search for javascript drag drop would help, and here's a few articles I found:
https://www.w3schools.com/html/html5_draganddrop.asp
https://medium.com/quick-code/simple-javascript-drag-drop-d044d8c5bed5
You would also need to submit the array of mappings using javascript. You could search for that as well, and here's an article I found:
https://codereview.stackexchange.com/questions/94493/submit-an-array-as-an-html-form-value-using-javascript

Related

How to combine tabular form and text area in one page?

I have a page, containing tabular data(region type SQL Query (updateable report)). It only updates existing rows using Submit. The wizard created ApplyMRU process. It works fine. But now I would like to place a text area in the same page, which will be bound to different table and will get updated once the same Submit button is pressed. How can I accomplish it?
I've created item for text area, but not sure what type of source I should set. Database column doesn't let me specify table. Also I guess I need a second after submit process, but not sure which one.
Keep your existing ApplyMRU infrastructure for the tabular form, and just define a second PL/SQL process that executes during page submit that will do whatever it is you want with your text area, eg:
insert into notes (id, text) values (:P1_ID, :P1_TEXT_AREA);
Take note of the order of the processes, as you may want to execute one before the other.

Making a Row Read Only in a tabular form based on table value

I have a tabular form which is updated throughout the year and i wanted to prevent users from editing certain rows. Currently the 'row type' is hard coded however I want the application admin to control which 'row types' are readable / write at certain times. My answered question, click here.
Currently a dynamic action is fired which prevents the rows that contain the type 'manager figure' and 'sales_target' being edited.
I have created a table with the three row types against each customer. Each status is set by a number: 0 to 3 (These i will decode into something meaningful for users).
0 - Row with that row type is read only.
1 - Users can enter into the row with that row type.
2 - row is read only with that row type.
3 - row is complete and set to read only.
I have created a new form (new tab) for the admin user to maintain each status.
Currently for Customer 'Big Toy Store' rows should be set as follows:
Manager Figure row should be read only (since set to 2)
Sales should be readable (since set to 0)
Sales target should be writable (since set to 1)
Please can i be pointed in the right direction, ive looked into jquery but struggling to work out how to pass the output of an sql query to it, so it can be used to determine which rows should be read only.
Link:apex.oracle.com
workspace: apps2
user: developer.user
password: DynamicAction
application name: Application 71656 Read only Rows for Tabular Form
I'm not sure that a tabular form is a good format to work out this idea. As you can see, you require quite a bit of javascript to produce the results you want. Not only that, but this is all client side too, and thus there are some security risks to take into account. After all, I could just run some Firebug and disable or revert all things you did, and even change the numbers. Especially with sales figures, which is something you most definitely do want altered by everybody and is also the nature of your question, security is important.
There are more elegant ways here for you to control this, and not in the least to reduce the amount of highly customized javascript code. For example, you could do away with the tabular form, and instead implement a modal popup from an interactive report. Since the modal popup would be an iframe and thus a different page, you can create a form page. On a form page you have a lot more control over what happens to certain elements. You can specify conditions, read-only conditions, or use authorization schemes. All things you can not evidently use in a tabular form.
I'd think you'd do yourself a service by thinking this over again, and explore a different option. How much of a dealbreaker is using a tabular form actually?
You need the user. You need to know what group he belongs to, and then this has to be checked against the different statusses and rows have to be en/disabled. Do you really want this to happen on the client side?
I'm not saying it can't be done in a tabular form and javascript. It can, I'm just really doubting this is the correct approach!

Explicit correspondence between Google spreadsheet cells and Google form input fields

I am making a web form for people to sign up for an event. I found that I can use Google form and Google spreadsheet for this task, and I started to learn how to use these web applications. I would also like to send the automatic confirmation e-mail to those who have signed up. For this task, I am also looking into the Google Apps Script. As far as I understand, I should define a function to send e-mail in a script in the spreadsheet and trigger this function at 'Form Submission Event'. I would like to identify the e-mail address of a person who signed up from the data he/she submitted, and I would like to include all the submitted data as well as the time stamp in the confirmation e-mail.
My questions are the following.
How can I identify the cell in the spreadsheet into which the value of an input field in the Form is stored?
Or, is there any way that I can read the values of the respective input fields from a Google Apps Script?
I would be glad if you could kindly refer me to an unambiguous API reference related to these questions.
So far I learned about the applications from the help pages provided in Google Drive,
e.g.
https://developers.google.com/apps-script/overview
However, I feel documents there are too concise.
I am learning how to send confirmation e-mail from this Google Apps Script:
FormSubmissionResponseEmail
I could not find a help document that explicitly relates an input field in a Google form and a cell in the Google spreadsheet. From my limited number of experiment cases, it seems that the time stamps are always stored in the first column of the spreadsheet. Is this guaranteed? It seems that 'namedValues' member of the 'Spreadsheet Form Submit Events' class is said to contain "the question names and values from the form submission." (https://developers.google.com/apps-script/understanding_events)
However, when I modified the Google form, the 'namedValues' member still held the elements corresponding to deleted input fields. Is there any way to loop over only those elements in 'namedValues' that corresponds to the fields actually input by a user?
I would also be glad to hear about alternative tools to replace Google form and Google spreadsheet.
This answer applies to the "new Forms", the 2013 version, not "Legacy Forms" which have been discontinued.
How can I identify the cell in the spreadsheet into which the value of
an input field in the Form is stored?
You can identify the column that will collect answers to a form question by the label in row 1. Armed with that knowledge, you can reference the answers by column number in functions such as getRange().
...is there any way that I can read the values of the respective input
fields from a Google Apps Script?
There are multiple ways to reference input values:
As you found in Understanding Events, using a function triggered by Form Submission you can retrieve input values from the event itself. Two options here; you get a set of values in an array, and namedValues that you can reference using the question text as a name.
You can read the data from the spreadsheet; within that same trigger function mentioned earlier, you could use e.range.getValues() to get an array with all the submitted values, which you could then reference by index. Remember that this would be a 0-based array, while the column numbering starts at 1.
From my limited number of experiment cases, it seems that the
timestamps are always stored in the first column of the spreadsheet.
Is this guaranteed?
Unless you modify the spreadsheet, the timestamp will be in the first column. It is possible to insert columns to the left of the data table created by Forms, which will affect where you would find your form results in the sheet (although e.range will adjust). The order of all following values will be the order that the questions were created in the form. Note that if you delete a column (because you removed the question from the form, say), the column for the "deleted" question will be recreated at the end of the row.
...when I modified the Google form, the 'namedValues' member still
held the elements corresponding to deleted input fields. Is there any
way to loop over only those elements in namedValues that corresponds
to the fields actually input by a user?
There are reasons for remembering past questions, although they are just a bother when they weren't used to collect any real data. Better planning can be used to avoid the problem!
Unanswered questions will be empty strings in the event (e.g. e.namedValues["Dead Question"] == ''). So you could skip them like this:
for (var ans in e.namedValues) {
if (e.namedValues[ans] != '') {
doSomethingWith(e.namedValues[ans]
}
}
Note, too, that you can get array of "headers", or the form questions, like this:
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var headers = sheet.getDataRange().getValues()[0];
...and then use a search of headers to find the column containing the answer you're looking for.

Looping through data over multiple pages in Django

I'm trying to find the best way to go about my problem and I would love your input. I am trying to allow users to scan multiple barcodes into a text area. After they are submitted they are split into an array. The user then inputs how many iterations of each value in the array are to be inserted into a MySQL database. I've achieved this using PHP and session variables, looping through the array one step at a time. With Django I've found it a little more difficult and I am wondering if I should just have a "temporary" table in my database that gets refilled with the values from the array of barcodes. The following pages then pull each value from the table instead of using any sort of session variables.
Edit:
I apologize for the confusing question. Let me try and clear it up a bit:
I need to render a view based on each value in the user-submitted array. When it is first submitted, a view is rendered for the first value. When the user hits "Next" a view will be rendered for the second value in the array, and so on.
As for the database issue, each value can have two "types." The user will declare how many of each type is added to the database in each of the views I am trying to render.
Thank you.
this is nothing about django.
forget that temporary table.
add a field "filled" to ur table
select 1st not-filled row, and show "refill" page by this row
then update user input number back to db, set "filled" to "true" at same time.
You probably can port your PHP solution using a Django session object.
I'm not sure if that "one item at a time" is a feature or a "it was easier to code that way" thing, but in the second case - you may want to use Django Formsets to display all items at once and avoid looping through the array.

How to link a SharePoint list with a Word form?

I want to store Word forms into a library and then use them to populate with data from a SharePoint list. Push data from the list to the forms, by selecting one of them.
Has anyone do it? is there a simple way?
This sounds like a mail merge kind of operation. Mail merge does not work with datasources with a HTTP path. The workaround to this is to map the document library as a network drive. When performing mail merge in Word, you would then select the drive as the source.
See Q 14 in this link for more info
[]: http://support.microsoft.com/kb/826838
Each list can only (I think) 1 form that is used as the template document.
Make secondary lists for each Word form.
If you have a primary input list, then a workflow that recreates a list copy in the secondary list as per the required form.
This should force the secondary lists to populate data onto the form as per each type, then save the form back to your primary list.
A bit out of the way, but should be able to be done.
You can use word (2007/2010) quick parts to pull metadata from SharePoint, but it works only if you use document library and not a list.