Dynamic columns based on rows - sharepoint

What I am doing might be really stupid, if so, please correct me, but I am trying to do the following thing:
I want to have a list with (for example) the following items:
List Addresses
-Name
-Address
-City
-Country
But, based on their Country, I want to display different columns that I want to record in a List. For instance:
CountryColumns
(United States - SSN - Yes)
(United States - State - Yes)
(United States - Province - No)
(United Kingdom - SSN - No)
(United Kingdom - State - No)
(United Kingdom - Province - Yes)
And then when the user picks United States in the country list, the next time the user edits his information, certain columns will be shown. (It's also possible that all will be shown, and that the next time the columns with No will be hidden).
I've looked at ways to do this, and I only found out that Infopath is able to do this. But, that'd mean I would have to create a different view for every country, and show / hide certain columns. It seems like that is a bit of overkill.
Anyone knows a way how to do this?
Greetings,
Mats

Here are three options:
Custom content types. This is probably the most SharePoint-y way to do it. You can create a content type for each Country and then control which fields are included in that content type. The obvious downsides to this are that you could end up creating a lot of content types and also that selecting a content type (especially when creating a new item) is not the same as selecting a choice from a dropdown list.
Javascript/jQuery. Either by changing your master page or by adding a Content Editor Web Part to your Edit Form, you could use javascript to hide certain fields based on the selected value of Country.
Custom fields. This is the most involved, but instead of having the SSN field be a regular Single Line of Text field, you could create a custom field that inherits from SPFieldText and then manages its render visibility based on the selected value of Country.

There are four ways you could modify SharePoint to do this that come to mind.
Have a list address content type and then a separate content type for each country that requires extra fields. Use a webpart to enter data to the list using the correct country's content type.
Same as above but instead of entering data through a web part, you can add the data into the list using the base address content type. Use an item adding event receiver to decide which content type to add the data to.
Use one super content type that includes all fields but with custom list view pages to filter the fields based on the county value.
Use infopath with either separate views for each country or a section for each special field with a condition to hide it if the required country isn't selected.
Personally I would recommend 4. It's the simplest and quickest to implement.

You cannot do this out of the box.

Related

How to create a sharepoint list column that links to another list that is editable

I'm not sure if the title is a proper descriptor of what I'm trying to achieve here, hopefully it's close enough. I'm not a SharePoint expert, but I'm comfortable with creating forms and workflows as necessary to get something like this to work.
Basically, I need to have two separate SharePoint lists that are linked together, but one list needs to have row level security to hide data from other users that shouldn't see it. I need the column that is being linked to be an editable text box though, rather than a simple lookup field.
For example:
List A
Customer (text)
Description (text)
Sales People (person, multiple selections allowed)
Expenses (linked field)
List B
Customer (text)
Expenses (number)
Created by (just a reference that the sales people would actually "create" each row here)
Essentially, multiple people can be assigned to a customer in list a. The "sales people" are assigned by another user who actually creates the item for list a. I need to be able to have the people who are assigned as "sales people" to have a text box where they can enter their expenses, but on an individual basis, that would then be stored in list b with row level permissions to prevent them from seeing each others expenses totals.
List B would be able to show each sales person their full list of expenses across all the customers they are connected to, but not be able to see each others expenses. It's not a problem if the person creating the item for List A ends up with items in List B that are 0, but I need to be able to have the Expense field be an editable text box from a form that allows the sales people to enter their total expenses for that customer.
If I was building a custom application, this wouldn't be difficult to do, but I can't for the life of me figure out how to do this in SharePoint, or if it is even possible.
This is possible, but it will require custom development, using the SharePoint Object Model. Create your two lists and then you can either create a javascript/HTML based solution using libaries like jQuery and SPServices, or you can create a custom web part and use C# to update the lists. There's lot of examples out on the internet on how to do this. Write some code, and bring any problems you have with the code back to StackOverflow.

Is it possible to create a Custom Column that will take values from a specific view of a list?

I have a list of products that has two columns, product and product family.
I want to create another list that uses this first list as a lookup for one of the columns. This I can do, i.e. I create a custom column and then use the "Add from existing site columns" linko the "List Settings" page of the second list.
However, what I'd really like is that the custom column only proposes products that belong to a specific product family. I can create a View in the first list which allows me to display only the products in a specific family. However I don't see any way to specify only this view when I create the custom column.
Anyone have any ideas ?
Best regards,
Colm
If I understood you correctly you are trying to make a dynamic select field that will populate based on what the user has chosen in a select field before it. You will not be able to configure this with out of the box SharePoint. It is possible to add some javascript to a form to achieve this. I believe you can also do this in InfoPath but I am double checking that.

Joining sharepoint 2007 lists in a web view based on a common key field

So - I'm making a data view that is to contain a list. This list has a field that will be used to match up against two other lists. If there is an entry for this value, it should show the value from the other list, otherwise show a link to add a new one.
So, what I need to do is make a data source consisting of the rows from list 1, and fill in the Ticket field with a value from the Tickets table matching the ID value from list 1. The same should be done for the Change Type field.
Can anyone point me in the right direction to accomplish this? I've found a few tutorials, but they seem to be for showing all the data together and not match up on any specific columns for linkage.
Thank you
What you are aiming at is not available in SharePoint out of the box.
There are two approaches you can look at:
Create your own custom lookup field template for single/multiple field
selection with some sort of field
editor. Create your own controls and
program the associated code behind
logic.
Use some existing custom solutions. One such sample is on codeplex:
SharePoint Filtered Lookup Field

Sharepoint: Person column in custom list

I have a Person field in my custom list. I want to have a view that will show multiple fields from that Person instead of the one I had to choose when creating the Person column.
So basically I want to have one column for Person and then in the view see Name, title, email, phone. All of those are valid choices but I can only pick one right now.
I really want to avoid typing in the username lookup for each column I choose to display.
This is SP 2007
It sounds like you need to create a custom fieldtype (with a fieldcontrol) that inherits from the userfield but in viewmode renders out the different columns you need. Is that something along the lines you are looking for?
http://www.sharepointblogs.com/nicksevens/archive/2007/08/31/create-custom-field-types-for-sharepoint.aspx
Note: This link is broken
You probably want a Computed Field. Note that this is not a Calculated Column. A Computed Field is what is used to display the same data is different ways. In SharePoint there is a Title field, but there is also a "Title (linked to item with edit menu)" computed field as well as a "Title (linked to item)" computed field.
See midway down this link for more details. I'm not sure if it will have all of the power that you need, but if it does it is almost certainly what you are looking for if you don't mind getting into the Schema XML file a little.
Could you use a DataView web part for this? If it's just a question of viewing the data that might be suitable.
Came across this thread and thought I'd add a tip. This suggestion is clearly not for every use case, but may work well in situations where you're managing a list rather than allowing manual inputs (verified to work with SP 2013):
Create a spreadsheet with columns to match your SharePoint list that contains multiple profile fields. (for example: name, phone number, email address)
In the spreadsheet, enter the same email address in all of the person/group field types in that row. (e.g., boss#company.com, boss#company.com, boss#company.com)
Select and copy the row(s) you wish to transfer to SharePoint.
In SharePoint, change the list view to "Quick Edit" and paste the row(s) into the grid.
SharePoint will process each field and convert the email address to the profile value you selected during the list setup.

Mapping Infopath fields to Sharepoint columns

Any one has any idea how to map an infopath field to a sharepoint column of type choice? The infopath field is a repeating field, so the user can select multiple options, I want to be able to map those to the choice field in sharepoint. Any ideas?
update:
What I'm trying to do is the following. I have a choice column in sharepoint which allows user entered values. In infopath, I have a repeating field. I'm binding the field to a dropdownlist. The dropdownlist gets filled by a webservice. This dropdownlist is in a repeating section, so the user can choose to select from multiple dropdownlists. So lets say the user adds 2 dropdownlists, and selects an option from each dropdownlist. I want to be able to add those selections as choices in the sharepoint choice column.
SharePoint list is a flat structure, and because of that Infopath does not allow you map repeating sections to list columns.
You might wanna consider the following workaround:
Store Infopath form to one library
(along with non-repeating fields)
Use one of these custom activities to extract data from
repeating table and copy it to
another list
Create a custom data view or a web part to display these items (if
necessary)
This approach can be useful if you need to do some additional tasks with the repeating data.
When you are promoting fields within a repeated section into SharePoint columns, the options available are to promote the column as:
first (i.e. only the first selection is promoted)
last
count
merge (I believe this merges all the selected values together into a single entry)
screenshot http://img4.imageshack.us/img4/5539/repeatinggrouptr3.png
Is it not similar to Create a Repeating Cascading List from:
a Flat Data Source or
a Hierarchical Data Source ?
If it is, may be those two articles may give you some pointers.
Depends on the type of choice field it is.
If it is a Multiple Select (checkboxes) Choice field, you can set the field through the object model (from the sharepoint site) or through the web service, by using ";#" for each item that you want to check mark, where is the value which is listed by the checkbox. I don't remember what the option is for single choice only, but it is something of the same nature. If you are talking about lookup fields, it has to do with the index number of the field from the list you are looking it up from. Also, there is additional steps if the choice field allows users to input or specify their own options.

Resources