Refinement values stopped to return "hints" - sharepoint

I have a problem with refinement values returned by the search in the SharePoint 2016. I do not know when this started to appear but maybe it is connected with the migration from SP 2013 to SP 2016? Later we have returned from the search refinements and the values looked like this:
Refinement Value: Organizational:ColAfterSyncUpg GP0|#1dc79002-d32b-4faa-89f3-08ab45051e70 L0|#01dc79002-d32b-4faa-89f3-08ab45051e70|Organizational:ColAfterSyncUpg GTSet|#4642cdf4-872b-4179-96f5-043fbadb0fcf GPP|#4f668d16-2643-436b-b72b-0f180ccae0e6
This value was taken from managed property which has attached two crawled properties:
ows_<managed_metadata_field_name>
ows_taxId_<managed_metadata_field_name>
. Thanks to that I could get correct GUID and in the search query pass some refinement filters. But now (I do not know when this started to happen), when I add a new document to an empty collection (without old, correct files) the search is crawling this field and returns only:
Refinement Value: Organizational:ColAfterSyncUpg
I suppose that the second crawled property (ows_taxid) is empty. But why? Did something changed in the SP 2016 and now this property is not created or what? "Old" files are crawled ok, "new" not ok...
EDIT:
Found out that when I edit the item manually, then everything is ok and the search returns correct values with GUIDS. So maybe there is something wrong with the code? The code is quite complicated but some parts of it:
var taxValue =
new TaxonomyFieldValue(field)
{
TermGuid = tagDto.TagId.ToString(),
Label = tagDto.DefaultLabel,
WssId = -1
};
field.SetFieldValue(entity, taxValue);
entity.UpdateOverwriteVersion();

I have found out what was causing the problem. One of my team members disabled events during document provisioning by our code. Looks like SP has some events which generate those values and events cannot be disabled if you need them.

Related

SharePoint 2013 on-prem Add-In EmailAssignTo on task list

I've created a Task List in my app web with a custom content type based on task. I want to be have an email sent when an item is assigned to someone.
Looking around it seems that adding EmailAssignTo="TRUE" to the List element in Schema.xml should do the trick however I see the following:
Warning 1 The 'EmailAssignTo' attribute is not declared.
EmailAssignTo doesn't seem to be documented by Microsoft. Am I going about this the wrong way?
Based on a quick PowerShell check/test the List property you want appears to be entitled EnableAssignToEmail, which expects a Boolean value.
Source documentation from MSDN:
https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.enableassigntoemail.aspx
SPList.EnableAssignToEmail property
Gets or sets a Boolean value specifying whether e-mail notification is enabled for the list.

Why does owssvr.dll return an empty result for my list?

I am trying to use owssvr.dll and its URL API in SharePoint 2007 to get some list metadata. For most of the lists in my site of interest, I can use a url formatted like so:
http://hts-app1/compounds/_vti_bin/owssvr.dll?XMLDATA=1&List={F987723C-28A4-47D3-83D7-19094B0267DF}
I get back an xml-based list of field metadata for the default view and a list of records in the list. But when I try to use another guid for a separate list, I get an empty response from the web server. It's a 200 response code, but the other headers look like:
Connection:close
Date:Thu, 24 Mar 2011 17:38:46 GMT
MicrosoftSharePointTeamServices:12.0.0.4518
Server:Microsoft-IIS/6.0
X-Powered-By:ASP.NET
I am pretty sure the list guid is valid, since I can match it with the guid for the list I can see in the listedit.aspx page. If I also format my url like so:
http://hts-app1/compounds/_vti_bin/owssvr.dll?XMLDATA=1&List={F987723C-28A4-47D3-83D7-19094B0267DF}&Query=*
with the Query=* parameter, I can get valid xml, but it's just showing everything, and not filtered for my view, and I'd really like to have the view.
I looked in the SharePoint log file, and I couldn't find anything that looked related to this request.
So, how can I debug this? I'd really like to use a simple http GET request to get back this metadata, and owssvr.dll seemed the ideal mechanism.
You can specify a specific view as well. Like this
http://{0}/_vti_bin/owssvr.dll?Cmd=Display&List={1}&view={2}&XMLDATA=TRUE
for example:
https://foo.com/extranet/_vti_bin/owssvr.dll?Cmd=Display&List=%7B7F7AFB9D%2D6D5D%2D4626%2DBD9D%2D085957DB79AB%7D&view=%7B111EC07E%2DF648%2D443B%2D8DE6%2DB53786BE6762%7D&XMLDATA=TRUE
The absolute easiest way to get the list and view guids is to goto edit the view and snatch the list & view info directly from the address bar.
1. That supplying GUID in the querystring of your URL works for one list and does not for other is probably because the lists are on different sites. Verify that the sitename is correct and that GUID is a List ID indeed.
Be wary of the fact that, however, above applies to both SharePoint 2007 and 2010, for SharePoint 2010 additional measures might be required depending on context from which you execute commands on owssvr.dll.
2.
query=* is not a filter parameter; it shows schema as well as data for all available columns in the list, including SharePoint internal columns, which normally you never get to see in ways other than programmatic access.
3.
To get only those columns that are visible in the current default view call display command on owssvr.dll while xmldata parameter is set true; like this:
http://hts-app1/compounds/_vti_bin/owssvr.dll?Cmd=Display&List={F987723C-28A4-47D3-83D7-19094B0267DF}&XMLDATA=TRUE
Again this is for SharePoint 2007 only and depends on execution context.
4.
with the Query=* parameter, I can get
valid xml, but it's just showing
everything, and not filtered for my
view, and I'd really like to have the
view.
Oh but this is not called filtering; filtering is only based on columns values. For this use additional FilterField1 and FilterValue1 parameters.
http://hts-app1/compounds/_vti_bin/owssvr.dll"
+ "?Cmd=Display&List={F987723C-28A4-47D3-83D7-19094B0267DF}"
+ "&XMLDATA=TRUE&FilterField1=YOUR_FILTER_COLUMN_NAME&FilterValue1"
+ YOUR_FILTER_COLUMN_VALUE
Takeoff "(double quotes) and +(plus) and (returns) before testing in browser.

Adding an existing site column to a custom list

I think I'm going mad - this seemed like an easy thing to do but I can't find any info on it at all.
I have created a Custom List and added 4 columns to it. Created By and Modified By are already in the list but hidden from the view.
I want to add a Date Modified column (which is a built in field) to this Custom List. How do I do this programmatically?
Are you trying to add the column to the list or to a view? The Date Modified column should be added to the list by default. To add it to the view (i.e. so it shows up when you navigate to the list) you can use code similar to the following:
using (SPWeb web = new SPSite("http://intranet/").OpenWeb())
{
SPList customList = web.Lists["CustomList"];
SPView defaultView = customList.DefaultView;
defaultView.ViewFields.Add("Modified");
defaultView.Update();
}
With sharepoint sometimes you must do ugly things... stuff you would not want your children know when they grow up.
Here is a pitifull solution:
- you create a DateTime field just like any other.
- you create a workflow when data changes, workflow starts, updates that your custom modified field and then stops.
ANYWAY, I know it is possible to show the default Modified field, perhaps you wanna go in that direction a little bit more.

Sharepoint alerts not working when multiple people are in an item

We use Sharepoint Services 3.0 as a project tracking tool. We have a list set up that contains your basic information (description, etc.) plus we have a "assigned person" column that is of type Person or Group that we use to associate list items with individuals. This column supports multiple selections.
We would like to set up alerts such that each person gets an alert email only if they are assigned to a list item. The approach we have taken is to set up a view on this list that is filtered to show list items where the assigned person equals [Me], and then to create an alert on this list that is set to send an email when someone changes an items that appears in the view.
This works well when there is only one person in the assigned person column. It does not work when there is more than one person in the assigned person column.
Does anybody know why this wouldn't work, or what I can do to troubleshoot? Is there a better way to achieve the end result? We could make several "assigned person" columns and not allow multiple selections, but that seems kind of kludgy.
Try this info site,
http://www.sharepointalert.info
it has a good alert trouble shooting guide.
The reason it works for one person but not multiple people is because the check is specifically against an individual. The comparison your view does is whether Assigned is equal to [Me], not if Assigned has [Me] as one of its entities.
Instead of using a list filter of is equal to, use the list filter contains. That should do the trick.
EDIT IN RESPONSE TO COMMENTS
To access the object model, you'll need to use Visual Studio. I'm unaware of a method to accomplish this kind of thing using SharePoint Designer, but maybe there's some sort of crazy Datasheet View thing you can do. Anyway... onto your actual needs...
The following code sample illustrates a very basic method for achieving your goal.
using (SPSite site = new SPSite("yourwebsiteurlhere"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["titleoflist"];
SPView view = list.Views["filteredviewname"];
view.Query = "<Where><Contains><FieldRef Name=\"assignfield\"/><Value Type=\"Integer\"><UserID Type=\"Integer\" /></Value></Contains></Where>";
view.Update();
}
}
Replace "yourwebsiteurlhere" with the website url, "titleoflist" with the title of your list in question, "filteredviewname" with the name of the view, and "assignfield" with the internal name that you used for your assignment field. If you created it through the standard SharePoint UI, this should be the name of the field without any spaces.
As far as where to run the code, you could put this kind of thing in a one-time workflow. I sometimes do that just to make sure I have necessary privileges. Hope this helps!
If you're not able to/allowed to use Visual Studio, then your solution will probably have to be to look into a 3rd party solution.

Problem finding Item List Id in WSS 3.0

I'm having a hard time figuring out how to refer to a specific Item List within a list in SharePoint. I looked up the page in SharePoint Designer and found that the listitem is inside a custom made webpart inside a custom made webpage. I'm coding an event receiver and need to read the information that the user types into that listitem which is a textbox. Does anyone know the code to do this or how to get the guid for the specific list item?
I would appreciate any help I can get. I have tried looking all over the web for the answer. Thanks.
It might be a good idea to edit your question with exactly what you'd like to do with the information you read. However from what you've said so far:
The ID of the item being edited will already be passed through to the event receiver via SPItemEventProperties so there is no need to look it up. If you need to look up a different item in the list (or indeed in a different list altogether), the Accessing list items using the object model page on SharePoint Dev Wiki gives you all of the options. A good general rule is use SPQuery to get best performance on the whole.
Note: There is a pretty good page on the SharePoint Dev Wiki demonstrating how to write an event receiver. It shows how to query and obtain a list item title.
Update after comments:
Once you have an SPListItem object, you can find its GUID through the UniqueId property. In the "Accessing lists" wiki link I've provided above the code samples show how to use the Title property.
Every piece of data you need to access within SharePoint should be available through the object model. This is a simplification, but generally the pages themselves are rendered from template files on the server and combined with data in the database to display to the user. So editing the page programmatically or through its source isn't going to work.
Apologies if I'm making an incorrect assumption but you sound fairly new to SharePoint development. I strongly recommend you read at least the first few chapters of Inside Windows SharePoint Services 3.0 as the inner workings of SharePoint are important to get a good understanding of and this book should help a lot. There is a section of event receivers in it as well.
Have you looked at SharePoint.ListsService Webservice?
string url = "WSS Site URL";
SharePoint.ListsService.Lists lists = SharePoint.ListsService.Lists(url);
XmlNode list = lists.GetList("ListName");
XmlNode xlists = lists.GetListCollection();

Resources