Thursday, September 22, 2016

Nintex workflow errors when setting managed metadata field values in SharePoint 2013

I was setting up a workflow today that was updating several fields on an item.  The workflow was not completing successfully, and the following error message was displayed:

Event Type: Error
Outcome: Unknown Error
Description: The workflow could not update the item, possibly because one or more columns for the item require a different type of information.

That is a bit generic, but it did point me to digging into each of the columns that was being updated.  I found that one of the columns was causing the issue and it was a managed metadata column type.  I was attempting to set the value to equal the display name of the managed metadata choice I wanted. 


 It turns out that the field actually wants the GUID of that value.  I was able to find this via the REST API.  It took a bit of time troubleshooting before I figured that out, so I wanted to post this and maybe save someone else some time.

To get the GUID, I started at the site level with a URL like this:
https://<web app>/<site name>/_api/web/lists/

Then, find the GUID of the list you are working with and add it to the URL
https://<web app>/<site name>/_api/web/lists(guid'<GUID>')/items/

Next, locate an item that has the managed metadata value you want to use in the workflow and look for the "TermGuid"

Copy that GUID to use in your "Update Item" or "Set Field Value" action in the workflow

That was the first workflow I have done that was manipulating managed metadata fields.  Good learning experience for me.  Hope you learned something, too!

Monday, September 28, 2015

SharePoint 2013: My suffix search workaround... calculated column inception

Although a bit frustrating at first, this was somewhat of a fun puzzle.  My client has a SharePoint 2013 site that contains files related to projects that are being managed in an external PPM system.  They want to do the content management for all of the related documents inside SharePoint. Since the core documents would be similar for each project, we went with document sets. We are expecting a very high volume of projects (in the thousands), so a very effective search experience is a must.

First, my standard search enhancements.  A result source for this location that pulls back only items from this library, but just the doc sets.  Since doc sets are considered a list item and also a container, I included this in my query transform: contentclass=STS_ListItem_DocumentLibrary  IsContainer=true.  I updated the search result display template to include a few key pieces of metadata, updated the refiners to leverage the custom metadata fields and turned on the refinement counts.

Since I have done this a few times now, I was able to put that together fairly quickly.  I expected to have it all wrapped up and then move on to the next order of business.  That is when my client presented a request that was a bit challenging to figure out.  The official project numbers they are using from the external system look something like this PRJ00002813.  They would like to be able to search just by the number without the preceding 0's or PRJ designation.  Ok, I thought, a calculated column to take the last 4 digits should work.  Not so fast... the project numbers could have 6 leading 0's, or 7, or 1, or anywhere in between.  They should all have the same total number of digits, but there may also be other project-like items coming in as well.  Those will have a naming convention that like IDEA0001234, which will also have a variable number of 0's.  Well, now this is getting interesting.

I was convinced that a calculated column would be the way to go.  After much time testing out calculations in Excel... many of which I had not tried before, I was able to come up with something that worked.


=RIGHT([TITLE],(LEN([TITLE])+1)-MIN(IFERROR(SEARCH(1,[TITLE]),99),IFERROR(SEARCH(2,[TITLE]),99),IFERROR(SEARCH(3,[TITLE]),99),IFERROR(SEARCH(4,[TITLE]),99),IFERROR(SEARCH(5,[TITLE]),99),IFERROR(SEARCH(6,[TITLE]),99),IFERROR(SEARCH(7,[TITLE]),99),IFERROR(SEARCH(8,[TITLE]),99),IFERROR(SEARCH(9,[TITLE]),99)))
Here is what the calculation is doing from outside in...  
  • The RIGHT function returns the last character or characters in a text string, based on the number of characters you specify. 
    Syntax
    RIGHT(text,[num_chars]).
    I am using TITLE of the item for the text, and have some nested formulas for the number of characters.
  • The LEN function returns the number of characters in a text string.
    Syntax: LEN(text).
    I am taking the number of characters in the title and adding 1.
  • This is being subtracted by a MIN function that returns the smallest number in a set of values.
    Syntax: MIN(number1, [number2], ...).
  • Within the MIN function, I have an IFERROR function that returns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula.
    Syntax: IFERROR(value, value_if_error).
    If there is an error (because the number doesn't exist in the item title), it returns 99 which won't be the smallest number in this set.
  • Finally, we have a SEARCH function which will locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.
    Syntax: SEARCH(find_text,within_text,[start_num]).  
I have a series of SEARCH functions, so it will look for each number that is not 0 and return the position of that number, the MIN function then uses the number that is in the leftmost position to subtract from the overall length of the title.  This number is then used by the RIGHT function to return just the numerical digits after the 0's.

Input
Output
PRJ00028987
28987
PRJ00029262
29262
PRJ00000010
10
PRJ00002758
2758
PRJ00002759
2759
PRJ00002760
2760
PRJ00002761
2761
IDEA33
33

The formula looks a bit crazy with the layers of nesting, but it totally works!  I made the calculated column a site column, so it would be searchable.  When I started digging into this, I was hoping to find something I could model it after, but I was unable to find any examples that came close to my scenario.  Hopefully, someone out there will be able to use this for a similar situation.

Thanks for reading!

Monday, May 11, 2015

SharePoint 2013: Make your site's search rock!

Make your site's search rock

If you are ready to get more out of SharePoint search functionality and help your content consumers find things much more easily, you have a lot of options available.  Below is a summary of a few approaches I have taken which people seem to find useful.  I plan on creating some future posts that dive into more detail.
Scope and dropdown options
First, the scope and options in the dropdown can be changed to just look at a certain library or multiple libraries.  It can even search other sites.  We can put multiple options in the dropdown to point the search at whatever you need. 
Here is an example we set up for a site collection dedicated to project sites:

The first option only returns results that are project sites.  The second option searches all content within the project sites.  The third option performs the "everything" search throughout SharePoint.
For a brief overview of the "Search this site" box and the "Find a file" search, check out this blog post: Find a file vs Search This Site
Refinement panel
After entering your query, the out of the box search will take you to a search page with refiners on the left side.  These can also be modified to allow you to narrow down the results based on categories and columns specific to the content.  So instead of Result type, Author, and Modified date, you can have refiners that use the columns in your lists or libraries.
Some custom refiners we used in this example are "Site name" and "File size".  You can specify other metadata columns from the lists and libraries as long as they are refinable managed properties to help people find the content much easier.

Search verticals
For the project site collection example, there was also a request to only search the titles of items in the sites, so we added that as an option below the search box in the results pages as "Titles only".

Best Bets/Promoted Results
You can have best bets that are just for your site.  So, if your team uses certain web applications, for example, they can appear in your search results even if they aren't inside of SharePoint.

These are just a few of the options available to tailor your search experience for your site to better meet your needs.  Thanks for reading!

Friday, May 8, 2015

SharePoint 2013: Find a File vs. Search This Site

You may have noticed that many lists and libraries have a "find a file" search box next to the list of available views.  You may also have noticed that there is a search box at the upper right corner of your site as well.  These offer different search experiences and one may work better for you than the other depending on what you are doing.  In this post, we'll explore the differences.

Find a file


Here are some important things to note about how this search box within your list or library works:
  • Scoped to the list or library – meaning it is only searching the content within that list
  • Does not use the ranking model – this means the results returned to you are all treated equally and the order of the results is the same as the view you are using in that list or library.  So, if you are looking at a list that is grouped by a category and sorted by the oldest item to newest, your search results will be returned that way too.  Depending on what you are looking for, this could be a drawback as the results that best match your search may not be at the top of your result set.
If you want to remove or add this "Find a file" search box from your list or library, click here: How-To: Add or Remove the "Find a file" search box

Search This Site  

  • Scoped to the entire site – By default, this search box looks at all content on the site with options in the dropdown menu to select Everything, People, and Conversations.
  • Uses the ranking model - The items that are most relevant (strongest matches to your search terms) will be displayed at the top of the results page.
  • Customizable – This, in my opinion, is a key feature that can make this a very powerful tool.  There are several things we can modify which will be outlined in a separate post: Make your site's search rock!
​Thanks for reading.

SharePoint 2013: How to add or remove the "Find a file" search box

​If you decide that the "Find a file" search box is not helpful for a particular list or library, you can remove it with the following steps
1. From your list or library, click on the gear icon at the upper right corner of your window
2. Click Edit Page
NOTE: The page will now be in edit mode
3. Click the down arrow in the upper right corner of the web part containing the list or library contents
4. Click Edit Web Part
5. Within the web part properties window, click to expand the Miscellaneous section and deselect the option to Display search box
6. Click the OK button
7. Click the Stop Editing or Save button in the ribbon section at the upper left of your page.
NOTE: this will only impact the search box appearing on the view you were using when you made the modification.  If you want to apply the change to the other views, click on each one and follow the same steps.
To re-enable the search box, you can follow the same steps and check the box.

SharePoint 2013: Custom search refiner for site name

I have found when people perform a search for a particular file or page, being able to refine the results by the site is pretty useful.  This can reduce the need to have to look at URL's for each of the results, which are not always easy to interpret.

The end result can look like this:


First, you need to make your site name property refinable.  


I made this change to the Search Schema in the Search Service Application (SSA) within Central Admin (CA).  


  1. From CA, click on Manage Service Applications
  2. Click Search Service Application
  3. Click Search Schema from the left nav under the "Queries and Results" section


Here are two options:

Option 1 - Modify the existing managed property to make it refinable



  1. Search the managed properties for "siteTitle"
  2. Click Edit/Map Property for the "SiteTitle" property
  3. Scroll down to the "Refinable" section and choose the option for Yes - Active
  4. Click OK.


Option 2 - Map the crawled property to another managed property that is refinable 

I chose this route, but I am not sure if there is an advantage to choosing one over the other

  1. Click Crawled Properties
  2. Search for "sitename"
  3. Hover over the property "ows_SiteName and click on Edit/Map Properties.
  4. From the "Mappings to Managed Properties" section, click on Add a Mapping.
  5. From the popup window, you can search for an existing managed property.  There are many empty refinable properties available for you to use (search "refinable").  In this case, I am choosing "refinableString08" because I do not have that mapped to anything else.
  6. Click OK in the popup window.  I have to scroll down to see the button, so it can be easy to miss.
  7. You can verify that the mapping saved by searching for the property and you will see the new managed property mapping

    NOTE: Changes to properties will take effect after the next full crawl.



Now that your property is refinable, you can add the refiner to your search results page(s)


  1. From your search results page, click the gear, then edit page
  2. Click the options arrow for your Refinement web part and click Edit Web Part.
  3. From the edit pane, click Choose Refiners
  4. Click on the managed property name for your refiner (SiteTitle if you made the default property refinable, or whatever managed property you used if you mapped the crawled property to an available refinable managed property)
  5. Click Add
  6. Enter text for the "Display Name". This is what will appear above this group of options in the refinement panel. It could be something like "Site", "Site name", or "On this site".
  7. Click OK.
  8. Click OK in the web part editing pane.
  9. Save the page, check it in and publish.


Run a test query and you should now be able to see the new refinement option in your results page.


If you want to add the search result counts to your refinement panel, see the instructions provided by Steve Mann 

Thursday, May 7, 2015

SharePoint 2013: Unable to create or modify a list item. "Server was unable to save the form at this time" error

Brief Description:

A client recently reported an error message was being received when they were attempting to create a new list item or modify an existing list item.


Error Message:

"The server was unable to save the form at this time.  Please try again."



Additional Details:

The issue was reported as an entire team having the issue and it appeared to be contained to a single list.  They had previously been able to add or change items in this list.  The team reported that after they relocated to a new physical area, they were unable to modify the list.  This turned out to be a red herring.  I was thinking it might be something with the browser on their new machines, but that wasn't the case.


Troubleshooting:


  • Confirmed this was not occurring on other sites or other lists.
  • I was able to create new test items on the list and modify items on the list successfully.
  • Confirmed the team could create new test items (with just test info).
  • Copied the list to our test environment using Sharegate and attempted to create the exact same record that was causing the issue for that team.  I put in the exact same data and I was able to recreate it.


They were typing in much of the info into the list, but there was one multi-line text field where they were pasting information in from their ticketing system.  This seemed to be the only difference between creating the test records that were successful and the unsuccessful records.  I did try pasting in data from that system in testing, but I just grabbed something from the ticket, and I didn't receive the error.  It wasn't until I used the exact few lines that they were using that it was re-creatable.

In looking closer at what was being pasted in, it appeared to be just text.  I changed the column type to plain text (from rich text), but this did not help.  I noticed some unusual arrow characters in the text. But when I had pasted into SharePoint, they did not appear.  I removed those characters prior to copying when I pasted it in, everything saved correctly!

It appears that those may have been some hidden control characters... if anyone knows for sure, please let me know.




Other related info:

During my research on this error, I found several other people had been experiencing it, but on a much larger scale and they had resolved those cases with and some of these approaches: IIS reset, removal of browser add-ons, restart the SharePoint Search Hosting Controller service.  If you are experiencing this issue and it doesn't appear to be caused by unusual characters being pasted into the list, you may find some answers in this article: Technet: The server was unable to save the form at this time. Please try again.