What is the correct way to save a list of items in a web form? - forms

There is some form in a web form. It contains the list of items that use can edit, remove and change.
When the server receive the list of items, it should update existing items, create ones and remove the deleted ones.
I only know the naive and quite ugly approach:
When server receives the list of items from a client, it gets the actual list of items from the database
Pass round the received list of items:
2.1. If element has the ID and database has the element with this ID, this element updates
2.2. If this element doesn't have ID or database doesn't contain element with this ID, this element creates
Delete all items, that were not in the received list (marked as deleted)
The updated list of items are returnded to the client (with new IDs), and client displays them
I feel, that there is more elegant solution, and, propably, established for this task.

I had the same challenge and i solved it like this:
1-First when you load the page, create a list made up of id and data.
2-then the user fill the data.
3-those items that user doesnt fill should be deffault value.
4- then retrive the list from database and delete it and put the updated list
Hope this helps

Related

Get all items of SelectMultipleItems from request and not selected ones

In flask, in a form I add and remove some items to a list ( they are selected form other lists) then I want to treat all items added to this list as selected items and add them to the database.
items = request.form.getlist('sellist')
the above solution returns just selected items, how can I get all items? One solution is to have a javascript to select all before submission but what is the best solution and best practice for this senario? Should I use a list or another control?

Google Chart - DataTable inside a form

I have a table created with DataTable of Google Chart, which has a column with a drop-down list. In this way the user can set the proper value of a row.
I am working in Python and Flask and I can retrieve the request data correctly. The problem is that the table, given the amount of data, is showed in pages, each one with 20 rows. When I retrieve the request I get only those 20 rows, so I have no way to know what the user set in the other pages.
How can I get the values of all pages?
Moreover, I noticed that when I change page and then I go back, the table forgets the user changes, so I think I should be careful also to this fact.
Finally, I solved the problem by using a dictionary containing all the changes made to the table and updating the html string inside the table to keep the content updated.

Sharepoint - Load a form's view based on user

I am using a data connection list to load desired views in an InfoPath form on SharePoint. I have a permission list with 2 columns: usernames and control group. My form on the main list loads a specific view based on what the username and group are of the permission list. You have to filter out the group based on the form's username() function to match the username column and set that as a condition to (on form load) change it to a specific view.
All this works, but the problem comes in when you have a user with multiple control groups. The filter only returns the first instance it finds. I can't think of a way to fix this. Maybe load the other list as a repeating table into the form, but then how would I reference that table in the conditions of a form load rule? Or is there a way to get a field filter to look past the first item it finds?
Update: I forgot to mention that I have to use a field to hold your filtered username:id:group aka group[title=username()] and then use that in the form load conditions. I think this is where the problem is, as this filter is what doesn't store all instances of the users id from the control list, but only the first.
SharePoint 2010 with forms created in InfoPath 2010
Are you querying the data in from info path or using visual studio, if you are querying in info path check the condition as Display name matches the username() and the query the data

Filemaker - Can I use a portal like a drop-down value list?

I am trying to work around a limitation that Filemaker 12 seems to have. In a value list that links to an ODBC attached SQL Server database, it doesn't display every piece of data. If there are 2 people with the same last name for example, it only displays the first person with that last name in the list. This is verified by the following in the Filemaker documentation (which I found after a lot of digging)
If the value list is defined to display information from two fields, items will not be duplicated for the field on which the value list is sorted. For example, if the value list displays information from the Company field and the Name field, and if the values are sorted by the Company field, only one person from each company will appear in the value list.
Portals on the other hand will find all the related data, I just don't understand how do something with the data once I get it in the portal. I essentially thus wish to use a portal AS my drop-down value list, and then to use it as I would have a value list (which is then to act as the key to do the rest of the lookups on the page to fill out the invoice.
The major issue here (other than this maddening choice Filemaker seems to make) is that the external file I am pulling the data from is an ODBC mounted SQL Server file, so I can't do something easy like a calculated field which would give me last name & " " & first which would make almost every person unique. Filemaker won't let me do that because it says I can't do that with a field that is not indexed. Any help would be greatly appreciated!
Assuming that we're starting with table MyTable and we're trying to get a ID from the People table for the selected person, which we'll call ID so that we can put it into MyTable::PersonID
Start by creating a new Table Occurrence of your People table and call it PeopleWhoCanBeSelected. If you want every person in the People table you can connect it to MyTable with the X relationship. If you want to show just a subset of the people you can build a different relationship.
Now, on a layout displaying records from MyTable you will make a portal showing records from the PeopleWhoCanBeSelected table.
In the portal put a button. When that button is pressed use the Set Field script step:
Set Field MyTable::PersonID to:
PeopleWhoCanBeSelected::ID
That should do it. You can make the button an invisible overlay on the entire portal record if you like, so that the user clicks on "the name" instead of "the button next to the name".
Now, if you want to pull additional data through to the MyTable record, you'll need to create a second Table Occurrence, called People with the relationship MyTable::PersonID = People::ID. Then you can get information on the specifically chosen person through that relationship.

Amazon Dynamo DB - Scan & Update table records - iOS SDK

Is there an option to scan & update a record in a DynamoDB table using a single API. Consider I have list of items in a Items table, with the fields (ItemID, ItemName, ItemAssigned). ItemID is the Hash key of the table. Items IDs are named like , Item1, Item2, Item3 etc., The users will not know what are the items are in the table. So, in the app, if a user taps "Get an item" button, then a random item will be fetched and assigned to him. Then ItemAssigned is set to YES. The Items tabe Then the item will not be assigned to any other user. This is what happens.
Steps:
1. Taps "Get an item"
2. Scan the first item from the Items table, where ItemAssigned = NO
3. Show the item in the home screen
4. Update the item in the Items table to set ItemAssigned = YES
This works good, if one user is trying to get the item at a time. The problem occurs when two users A & B are trying to get an item at the same time, and the same item is assigned to both the users.
So first A fetches the item. Before the Items table is updated to set ItemAssigned = YES, B also fetches the same item. Now both A & B's home screens show the same item. This is wrong.
The only way is to Scan & Update the Items table using a single API. Is there any possibility to do this in Amazon DynamoDB?
Thanks.
Unfortunately there is no API that scans and updates in a single operation. You may want to look into conditional PUT item as this will allow you to implement a checkout like feature such that you can set "ItemAssigned = YES" only if "ItemAssigned = NO".
Your application code will need to handle the exception gracefully when dealing with a scan result, but will allow for the workflow you're requesting of only allowing one user to see the item.
API docs for PUT item