Sharepoint: Establish related records when new item being added to list - list

What is the best way to implement a parent-child hierachy between items in a list? The requirement is as follows
-> there is a list item with a particular ID
-> that particular ID could have related records.
-> all those related records should show up when viewing the list item
When the user adds a new item to list using a form, they should have the option to choose whether the new item being added has another related item or not.
The primary question here is what would be the best way to establish this hierarchy in the list? Also, all the items would be in the same list so how
would we link the list to itself? Or, what would be the best way to implement this? I can figure out several approaches to handle this within the confines of the
sharepoint server object model; however, this needs to be done primarily within the UI of Sharepoint itself (webparts, features, etc. may be used). However,
I am not sure how to IMPLEMENT THIS WITHIN THE SHAREPOINT CONTAINER ITSELF.
Any ideas/insights would be greatly appreciated.
Thanks

You can create a look up column in list with a parent list as itself and allow multiple selections. That way you will be able to check multiple parent IDs for a specific list item.
To show related list items, you can customize details view page of the list in sharepoint designer and add list view web part or dataview with appropriate filters based on the current item.

Related

Basic List on Entity Form

In Dynamics CRM online, I can add a list of entities to another entity, for example a list of products to an opportunity.
Is there any way I can have a list that is not picked from pre-populated items, e.g. just a simple list of {number, date, text} that you type in each time you want to add to the list, not picking items from a pre-defined list.
I am just using the web interface to customise at the moment, but I am open to any suggestions.
EDIT:
So far i have;
Created two entities, proposal and proposal version
Added a 1:N relationship between proposal and proposal version
Added a sub-grid to the proposal form, tried to make it editable but it refuses to work
This lets me add new rows by opening up the proposal version form and adding a new one or picking from already created ones for other proposals but that is rather clunky for a simple list.
I don't want it to offer to search for previous entries, just let me add to the list by typing stuff in, surely this should be fairly simple?
If you want a pre-defined list of items that are simple (number, date, text..) then you can create an option set field in CRM. These lists are fixed and can only be extended by customising the system. An example option set field might be Organisation Type:
Prospect
Site
Head Office
...
If you want a pre-defined list that can be extended, you need to create a new entity. Following from the previous example, you would create a custom entity called Organisation Type and then create a record for each type you wanted, populating only the name field with the type: Prospect, Site etc.
Then you would add a lookup field pointing to the Organisation Type entity on any other entity that used the field, such as Organisation (Account).
You see how the custom entity still appears as simple data because you're only populating the name field, which can be text, a number etc. You can also apply security roles to this entity, limiting which users can create and delete options from your list.
Edit: to only allow the creation of new records in a subgrid, make sure the lookup attribute to the parent entity on the child entity is business required.

How to Access Sitecore_Web Database Tables using Sitecore API

Hi i m new to Sitecore. I want to know how to access any table values from Sitecore Web Database through Sitecore API as i want to fill dropdownlist from a table inside sitecore_web database.How can we use Sitecore Queries to access data from Sitecore_Web Database?
I don't suggest you to access directly Sitecore_Web Database.What do you want to do exactly ?
Sitecore Api has a lot of classes, methods for accesing sitecore items but you don't access directly databases .
Maybe this link will help you.
You need to create some items to fill your dropdown list.
An item is a record in a database. Items are the basic building block of a Sitecore site. An item may represent any kind of information, e.g. a piece of content, a media file, a layout etc.
Items always have a name and and ID that uniquely identifies the item within the database. Items have a template that defines which fields the item contains. An item represent a single version of piece of content is a single language.
An item can be retrieved from a database using Items.
An item may have a number of subitems or children. These child items can be accessed through the Children property. The resulting items are checked for security and workflow before being returned. So while an item may have subitems, the current user may be denied access to them. The Parent property define the single parent item of this item.
An item represents a single version in a single language of a piece of content. The language of the item can be obtained from the Language property, while the version is available from the Version property.
The item must be in Editing state before the name or any field values can be changed. If not, an exception is raised. To enter the Editing state use the BeginEdit method and to end it, use the EndEdit method. The EditContext class can be used as a shortcut to BeginEdit/EndEdit.
I get this from Sitecore Api Documentation
As sitecore climber stated, you would not access the Sitecore database directly - this is not something which is supported by Sitecore. Typically you would achieve this through the Sitecore API using the following steps:
retrieve a node from the Sitecore tree which contains child items representing your dropdown items
retrieve the child items
databind your dropdown list to the list of child items
In an ascx, you could have something like this:
<asp:DropDownList ID="exampleDropDown" runat="server"/>
and in the code-behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
var item = Sitecore.Context.Database.GetItem("/sitecore/content/SiteData/StuffForADropDownList");
if (item != null)
{
exampleDropDown.DataTextField = "Text";
exampleDropDown.DataValueField = "Value";
exampleDropDown.DataSource = from i in item.Children.AsEnumerable<Sitecore.Data.Items.Item>()
select new
{
Text = i["Text"],
Value = i.ID.ToString()
};
exampleDropDown.DataBind();
}
}
}
This example assumes that you have an item at /sitecore/content/SiteData/StuffForADropDownList with some child items, which each have a field called Text.
Default in Sitecore you will NEVER work with real database objects other then objects filled using the Sitecore API. Sitecore API will provide you with data from your Sitecore back-end.
If you want to fill a dropdown with a list of items as datasource try something like this:
var items = Sitecore.Context.Item.GetChildren().toList();
yourdropdown.Datasource = items;
yourdropdown.Databind();
Obviously setting your Datatext and Datevalue key correctly, but that's standard .Net.
In Sitecore, never directly get data out of your database and use the Sitecore API.
Please use the built in services to access the sitecore items. It provides the option to select the database in the Get Item method.
You can access the sitecore service with the below URL:
{Your Site}/sitecore/shell/webservice/service.asmx

JSF selectOneMenu not whole List

Is it possible to choose only specific items from the list in selectOneMenu?
For example. I have List Products has many fields like name, id etc. One of it is category (1,2 or 3) I want to have only one category in the selectOneMenu without making new Lists and new classes. Can you help me?
I think the easiest way is to set the value attribute of f:selectItems to a method which filters your original collection.
Otherwise you'd have to implement your own version of f:selectItems which allows filtering - as we once did in one of our projects.

Unique Column in WSS 3.0 List

I am trying to implement a feature in a list from WSS3.0.
Basically I have a list and I want to add items to the list but I want to check first if there is already any item with the same value in a specific column.
I have a column named "My Key Field" and I want the values in this field to be unique. So, for example, if I have a record in the list where "My Key Field=65 210" I should not be able to add a new item when a users inserts the same value for the "My Key Field".
Any ideas on how to do this? A simple solution would be great considering my lack of skills concerning to Sharepoint programming....but I am flexible and I can learn.
Thanks for your attention!
Regards,
Aganju
The SPServices library has a method for this, called SPRequireUnique. It relies on SharePoint Web services.
For the record, you get this feature out of the box in SP 2010.

Filter external list fields from client

BACKGROUND:
We’re developing a custom application which access SharePoint through the Client Object Model and this application need to access ECT (external content type) lists defined in SharePoint using the OM (Object Model). This application is a product that should be usable with most SharePoint installations and configuration and cannot have prior knowledge of External Lists.
When there are no filters set up for the ECT, SharePoint returns all the available items in the list (given the number is below the threshold). The moment we define a filter for this ECT, SharePoint return only the items after this filter is applied (probably correct behaviour from SP).
PROBLEM:
We need to be able to search this ECT list (non-filtered) based on text entered by a user in a search box. At the moment there seem to be no way to change the filter SharePoint applied when returning the values to the calling object.
I.e. I have 10 items in my ECT list (1,2,3…10). Each Item has 3 columns (ID, Name, Description). After setting up a filter for the ECT list, SharePoint return items 2, 3 & 6 when I ask SharePoint for a list of items.
No the user does a search the matches the description of item 7. How can I search/filter the list to return the item that match my search query?
I’ve been running in circles trying to solve this, but nothing seem to work. I tried setting the CAML query as well as the LoadQuery as defined in both http://pholpar.wordpress.com/2011/02/09/how-to-query-external-lists-on-the-client-side-using-caml/ and http://msdn.microsoft.com/en-us/library/ff464384.aspx but nothing seem to work.
Even I had this problem. Let me tell you there is no way of doing this.
Even in Server object model, there was an option to change the filters of the default view but then the SPList will return 0 items once the filter is applied.
The funny part is once your code runs & you open the list in SP UI, you can see the actual modified list. But the same cannot be queries in the object model.
Looks strange. I guess if you modify the SPList (ECT based) in this instance, then you can only get results in the next instance (like in next page refresh.....)