Problem with a custom content type - sharepoint

I've made a custom content type based on the "Page publishing".
In this content type, I've also made a lookup field that lists all items in a list (nothing special with that list though)
When I use my own user to look at a page made with my custom content type, no problem.
When the site is crawled, the crawler doesn't want to index it giving me the error :
“ Content for this URL is excluded by the server because a no-index attribute.”
So I logged in with the same user as the crawler, and when I try to see the page, I get this error :
The page you selected contains a list that does not exist. It may have been deleted by another user.
Still, with that user, I can see the list that is used in the lookup field without any problem...
Any idea?

Related

ViewPath query parameter in SharePoint list causes CSOM to fail Lists.GetById

It seems due to a recent SharePoint Online update that their lists (when selected using the left navigation) now adds a ViewPath query parameter by default. With this change, it seems like the Provider Hosted App redirect now sends a different ListId and not the Id for the actual list. When I use CSOM to resolve the ListId it results in a "Site Pages" and not the list at all.
clientContext.Web.Lists.GetById(ListId);
This code base did work before the recent SharePoint Online update but now I cannot call my list. If I manually remove the ViewPath query parameter from the list then the redirect shows the correct ListId and CSOM resolves the correct List. The problem is I cannot expect users to manually remove that query parameter.
If I navigate to the list by using the Site Content page and not the left navigation then this query parameter is not present and my application works.
Does anyone have context or direction into how to handle this new change?
I have a similar issue on our site. Instead of modifying the list, a script web part on the initial page seems to bleed through. I have ammended the links in the lefthand nav bar in an attempt to circumvent the viewpath query being added. I put in 2 url carriage returns on the end of the link. So far so good for me.

Get listitems from Current Site

I am trying to create a Page Layout, that should have a lookup field. Lookup field should always get populated with a list's items.
This list will exist in all subsites, so whereever I create this page, list should get populated with listitems from current site.
I tried using site column lookup field, but it always point to list under top site and not the current site.
Any suggestion on how to make it work or better alternative? Thanks!
Let me know if I can provide more info.
The most straightforward solution I can think of is using a cross site lookup column and creating a seperate fields for each subsite. However, you will need to create and use different Page Layouts for each subsite.
You can use http://sp2010filteredlookup.codeplex.com/ for cross site lookups.
Solution 1 - Use http://sp2010filteredlookup.codeplex.com/
Use filtered lookup solution. So let's say you have your custom Page Layout and custom Page Content Type.
Every time you create new subsite, you should remember go to Pages list settings and edit Page Content Type by adding cross site lookup (with the same field "internal name").
So you still have one Page Layout (and one Content Type). But for each Pages library instance, Content Type contains diff fields (but with the same Internal Name). It will allow you run CAML queries and other things needed without any problems.
Solution 2 - develop custom sharepoint field type.
In edit mode, control will render "dropdown list" and populate data from list instance that is on current subsite. In the field settings you can have relative list url.
Solution 3 - hidden text field / js snippet solution
Page Content Type can contain hidden text field (it can contains selected field value in json format for example). Develop js snippet that will handle all the logic (rendering in edit/view mode, saving etc) and put it on Page Layout (aspx).
I would suggest to use solution #1 or #2.

Sharepoint: Change page layout and content type for specific page

I have a page layout in a solution I have deployed. The page layout also has a custom content type associated.
I wish to update this page layout and content type, but only for a specific place on the site. The reason is that for important "operation updates" we want the ability to send out SMS's to subscribed users (a built-in feature of Sharepoint for lists) as well as e-mail them.
The way this works is that I wish to add a boolean field that decides whether SMS's are send or not, and a field to put in e-mail adresses you want notified of the message.
My approach so far has been:
Create an event receiver that checks whether the fields are selected / filled out and do the actual sending.
Alter the layout page with the 2 new fields.
Alter the content type with the 2 new fields.
However, I am afraid of the complications for the rest of the site. For now, future uses of the page layout is not a concern, just the existing uses.
I know that updating a content type through XML definitions does not happen automatically, so on that side I'm safe, but how do I keep the layout page "contained" to the specific page in question?
EDIT: How do I show the two fields only when editing the page, not when showing it? Currently, my development site shows the edit form just right, but when I go to show the page it shows "yes" where boolean field is located and any e-mail adresses entered where the e-mail field.
Are you sure the page layout is associated with the content type, and that it's not a page that is associated with the content type?
If you want fields to be automatically added, you can:
Create a custom rendering template
that is used by the New/Edit/Display
forms for your list
(http://weblogs.asp.net/sharadkumar/archive/2008/07/07/how-to-customize-rendering-of-sharepoint-list-form-fields-part-1.aspx)
Create a custom ListFieldIterator (or use the default one)
that will automatically pick up new
fields in your content type
(http://msdn.microsoft.com/en-us/library/aa543922.aspx)
Use code in a DLL to iterate through
your content type's fields and thus
create the necessary controls for
your page all in code. If you use
FieldControls
(http://msdn.microsoft.com/en-us/library/dd571480.aspx),
it will automatically create the
default template rendering for the
field (i.e., it will display radio
buttons, drop down boxes, etc., as
defined by the fields in the content
type).
In your EDIT, when you say 'when editing the page', I'm assuming you mean 'when viewing the edit page for the list', and not 'when editing the page definition in Sharepoint Designer'.
Assuming that assumption is accurate, you can have the edit page for the list show something completely different from the view page for the list (and from the new page for the list). The pages are, by default, defined completely separately, and are edited completely separately. However, if you are using something (such as the ListFieldIterator) that automatically picks up the list of fields for the content type, you can create a custom Field Control for the fields you want to hide and have the view template for the field control set to display nothing.

How did I get multiple lists with the same name in my SharePoint site?

I have a SharePoint site that's being created from a custom site definition. The site definition has the following Features:
A custom content type.
A custom list template whose schema.xml file refers to that content type.
A list instance feature which refers to my above list template feature.
During the site provisioning process, I activate each of these features (each is at the SPWeb level) through C# code in the order above. My resulting site looks as I expect and seems to work fine, but it has the weird artifact that the "all site content" page for my site shows my custom list twice.
My list acts okay -- its item receivers fire correctly and only once. In SharePoint Manager (SPM), I also see the list show up twice, and when I expand the tree to look at the attributes, they appear identical across the two lists (even the list items inside the lists). I suspect that I may be fooling myself and SPM might be just looking at the same list twice, while some actual rogue list lies in the dark shadows of my site.
So, what could have gone wrong here? How could I have created multiple lists of the same name? How can I correctly create this list? And how can I properly clean up the weirdness in existing sites that exhibit this behavior?
Edit:
In response to Michael Stum's question, I created this console app to loop through the site's lists and get the ID:
using (SPSite site = new SPSite("http://myserver/projects/myproject"))
{
using (SPWeb web = site.OpenWeb())
{
var lists = web.Lists;
foreach (SPList list in lists)
{
Console.WriteLine(list.ID + ": " + list.Title);
}
}
}
This code shows my list twice -- same title, same ID.
Another edit:
I looked in the SharePoint content database for this site, and I executed this query:
SELECT * FROM AllLists where tp_webid = '<my SPWeb guid>'
This reveals that there's only one actual list with the title and GUID that I retrieved from my C# code above. So what is causing these multiple entries to show up when I'm browsing through my site?
I've come across with this issue several times. It's not a bug, most likely you have semantic errors in the elements.xml of your list template.
If a list definition contains more than one default view, the symptoms you described above will show up. Check the elements.xml file of your list template and make sure you don't have more than one View-Element with in it.
Kind regards
Ramon
I suggest you put a call in to Microsoft, this sounds like a bug.
P.S. without seeing the actual solution that creates the list we can't determine what's happening, perhaps a feature got activated twice...
Today I came across this issue and after reading the above answers I came up with an easy solution. Just create a new Default view and the Document library will show up normally again.
Kind regards,
Thijmen Groenewegen
P.s
I "created" the same two libraries by migrating the library from one place to another. At the old place the library was only showed once. If I look at the default views on that library two views are checked as Default.
Groenewegen is spot on.
I ended up with two Announcements lists on a site after I ran Export-SPWeb on a subsite and then Import-SPWeb to move it to a new site collection.
To fix it, I created a new default view for the list, All List Items, selected one of the two All Items views and deleted it, and the issue was fixed.
The Announcements list was being displayed twice on the View All Site Content page, and the data was being shown twice when viewing the All Items page.
Also, an intermediate step that you have to take before creating a new default view, is to open the list or library and add "?contents=1" to the URL so you can open the web part maintenance page and "Close" one of the duplicates. You have to do this because the web part ribbon will not show up on the Announcements page if multiple web parts exist, and you need the ribbon to access the view drop down and create a new view.
Have you tried with:
list.RootFolder.Name
(which shows the "internal" name - a part of the url)
list.Title shows the displayname (which can appear twice or more).
This could also be the explanation why you get multiple lists. You have maybe added them with the same displayname but dirrerent "internal" names?

Sharepoint managed Properties

Moved to Server Fault:
Sharepoint managed Properties
I have a custom Content Type inside a list that has over 30 items, and I have added several "managed properties" to the "crawled properties", in the SSP.
All of them work except 1.
The column "Synopsis" is a multiline field with no limit on it's length. It appears as a crawled property "Synopsis", and is mapped to a managed property 'asynop'.
On the 'Advanced Search Page', it is added as a property and searchable, however it only returns a partial result (if at all). I manually created an entry, ran the crawl and was able to search for it. I edited an existing entry, ran the crawl (full and incremental), and it still only returned the manually entered entry.
If I entered the search term in the Search box directly "synopsis:fatigue", then all the correct results appear.
What the is happening? And could it please stop?
This is a known issue and is dependent on what type of search is executed.
See Steve Currans great answer to this post: http://social.technet.microsoft.com/Forums/nl/sharepointsearch/thread/f3f1d778-796e-4321-9c76-a6ede421a42f

Resources