Email Enabled Calculated Fields

10 05 2017

I am back! Today I am going to show you how to use calculated fields to form an email address and a clickable link to send to that email address you just created.
The ask was to create a custom list that had the following fields:
Cost Code
Address
Location City
State
Phone
Manager
This information just happened to be avaialable in another SQL database, so rather than populate it it manually, I decided to go BCS all over that sucker. BUt, that’s not what we will talk about today.
Once that information is safely in SharePoint via external contentype, I used 2 calculated columns to get the email and the mailto link.
The first calculated column was used to concatenate the cost center and location to form the much needed address. So if you are following at home create 2 calculated columns.
The first colum will take Cost Code and Location city, mash them together and spit out an email address the address in the following format store40001portland@mystore.com
Since i have no column named store, i will just hard code it in. Here is the email formula:
=CONCATENATE(“STORE”,[Cost Center],Location_City,”@mystore.COM”)

Now, to make it a clickable mailto link, i really had to mess with the html. For your second calc column add this formula:
=CONCATENATE(“Email“)

You guessed it, EMAILCALC is the name of the first calc column.
that’s it.
Love me.
Nando

Advertisements




Buttons, Buttons, Buttons.How to create a Sp 2013 Javascript button to create a new doc

6 04 2016

You know what’s not so easy in Sp2013? Newform.aspx urls. Sure they live in the document library ribbon.
Sure you can also just drag stuff in, but what if you want to create a custom page and make it even easier for your users to create a new document?
That’s not so easy. So i set about figuring out the best way to do this.
Javascript buttons look cool and professional, so I thought, hey why not.
So I scoured the interwebs for some code. I came across this Gem by Ahmed Farag:
https://blogs.msdn.microsoft.com/how24/2014/09/23/create-a-link-to-display-edit-and-create-new-items-from-a-dialog-layover-in-sharepoint/
Thanks Ahmed you got me started!
This is an elegant solution if your library is out of the box. But what if you have custom content types?
That is not so easy to figure out. Once i did figure it out it was easy but not at first. You see, if you add a custom content type to a document library, the content type lives in _layouts, not in list/library name.
So how do you link that?
Well my friends, I am glad you asked.
First things first, like Ahmed says, grab yourself a content editor webpart (not script editor, that one has issues) and add it to a page.

Open your fav notepad editor
Copy Mr. Farag’s elegant code into it and click save.

 

(script type="text/javascript")
 function displayLayover(url) { 
 var options = SP.UI.$create_DialogOptions(); 
 options.url = url; 
 options.dialogReturnValueCallback = Function.createDelegate( 
 null, null); 
 SP.UI.ModalDialog.showModalDialog(options); 
 } 
 (/script)
Upload to your site asset library and link it via web part editor propeties
Now you have a pretty nifty button, but it doesn't do anything.
According to Ahmed, you should add the HREF key after your code for newitem.aspx.
However, as I alluded to early, that's not going to fly if you have a custom content type.
So here is his code:
<a href='javascript:displayLayover("/Lists/Contacts/NewForm.aspx?IsDlg=1")'>Display Item </a>
As you will figure out, content types do not live in /list/, they live in _layouts. So, how do i get that darn URL?

Its actually stupid simple. 
Basically, all you have to do navigate to your library settings, advanced settings, and find the open forms in dialogue, and click no.
Go back to your library and click new document and select your custom content type.

That will open your new item in a page, where, gasp, you can copy the url and past it into Ahmed code.

<a href='javascript:displayLayover("http://mysharepoint.domain.com/_layouts/15/NewDocSet.aspx?List=bc691a02%2D6335%2D4aee%2Da0e8%2D70185ab0491e&Source=http%3A%2F%2site%2Edomain%2Edomain%2Ecom%2F15%2Fnewlibrary%2FForms%2FAllItems%2Easpx&ContentTypeId=0x0120D520006B5814CAEDD0FD4C8F8F5C6B8AD7978C00F45CB6B8B2D5A74C8046CA70881BB0F7&RootFolder=%2F15%2Fputthisinyournewlibrary")'>New Content Type </a>

That's it. Now you have a new button that creates your new content type.

Tips: Make sure when you use content editor you upload your code to the asset library and link the file inside the content editor, so you can edit it easier.

TIP: Turn on versioning in your asset library so you can version your code out.

 

You are welcome world!

Nando





Dynamic Link to a specific Infopath Form View using a SP Workflow

11 12 2013

I had a requirement to create an infopath form for a client for assigning security badges. Not a difficult thing to do, I said. But as I gathered the requirements, and confidently shook my head back and forth saying, YES WE CAN!, I realized something nagging in the back of my mind.
I of course paid no attention to it and got to work on the infopath form.

It was nothing complex, just a user input form and an approval section at the bottom for official use only. But then that a fore mentioned nagging feeling, finally surfaced. I was going to have to use infopath views to hide the official use only section from the user. Simple enough for infopath, but now i had to surface a link to that view in a custom workflow email. That one took a bit of investigation, but i found 2 solutions for this. I will give credit to both parties, but i had to combine them to create one DOJO worthy Solution.

The first part of the solution can be found here. Kudos to  S.Y.M. Wong-A-Ton  for blogging about this.

http://www.bizsupportonline.net/browserforms/create-sharepoint-designer-workflow-send-email-link-infopath-browser-form.htm

The second part of the solutions comes courtesy of the wonderful Laura Rogers. Nicely Done!

http://sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?List=daba3a3b-c338-41d8-bf52-cd897d000cf3&ID=133&Web=dbb90e85-b54c-49f4-8e97-6d8258116ca0

Here is how I did it.

  1. First in SharePoint Designer 2010 i created a simple condition :
  2. “if current item equals value then Email a user”
  3. step1
  4. In the email editor I created a custom link and in the string builder i copied the following url and filled in the blanks.
  5. http://ServerName/SiteName/_layouts/FormServer.aspx?XmlLocation=[INSERTLOOKUP] &Source=http%3A%2F%2FServerName%2FSiteName%2FLibraryName%2FForms%2FAllItems%2Easpx&DefaultItemOpen=1
  6. From the string builder I clicked on add or change lookup and inserted the following in the [INSERTLOOKUP] referenced above.
  7. Data Source = Current Item
  8. Field From Source = Server Relative url. step3
  9. The new Url should look like this:
  10. step2
  11. I adde a reference to the hidden view using : &DefaultView=hiddenview
  12. Save and publish the Rule and test it out.
  13. The url link should open the infopath form with the new default view.

VOILINS……i mean voila.
Enjoy
Nando

 

 





SharePoint 2010 Documents Failing to upload in the morning.

25 10 2013

This was by far the most complex and vexing issue I have encountered in SharePoint. A little background on this first.

Everyday users would get the following errors BUT ONLY IN THE MORNING!!!:

con1

con2

con3

con4

 

This by itself seems quite strange to begin with, so i started down the familiar troubleshooting SharePoint path, starting with event viewer, then uls, then fiddler, then pulling out my hair, then calling Microsoft and then pulling out my hair some more.

I tried modifying the web config files for max upload time and ASP timeouts with no luck.

I looked at Load balancing settings and that yielded a dead end.

One promising direction i started going down was investigating the famed warm up script. This particular direction seemed fruitful. I wasn’t exactly sure that the warm up script was warming anything up. I asked one of my colleagues (sp dev, and a talented one) to help me create an automatic document upload script. Why an automatic upload script you ask? because after the first couple of users uploaded a document to SharePoint in the morning, the rest of the day it worked fine. So we created this band aid work around till we could figure out why it was happening.

So band aid in place we continued testing with fiddler and we found this little nugget of stress:

Tuesday, October 22, 2013 12:28:00 AM Start Upload http://prodservers/DatabaseWarm-upFile.docx

Tuesday, October 22, 2013 12:29:41 AM Upload Complete.  Duration = 100.7616918

Interesting. All uploads at 12 am where taking over at 100 seconds. I looked for timer jobs that kicked off at midnight and i found quite a few, but they were default SharePoint timer jobs. I didn’t think messing with those was a road we should go down. However, looking at performance data we could NOT ignore this particular spike in IO. My dev colleague identified [dbo].[proc_UpdateStatistics as the culprit. This is the stored procedure that was causing the issue.  There is an actual health analyzer rule that kicks off this timer job.

analyzer

I had never heard about this before so i took to the net to see if anyone had this problem.

Thanks to Chun Liu’s blog we found this:

http://blogs.msdn.com/b/chunliu/archive/2011/11/17/auto-update-statistics-and-auto-create-statistics-on-or-off-for-sharepoint-2010-databases.aspx

What? I say, what? How have i been working with SharePoint this long and never heard of this at all?

Needless to say, the fix that worked for us to was to set auto create statistics to false on all content databases.

Be warned that this should only be done in content databases and not search ones.

Resolution

At midnight upload files went fro 100 seconds to 2 seconds.

This took me 3 months to diagnose and fix.

Enjoy this golden nugget! Learn from my fail.
Nando

 

 





SP 2010 Disabling site Publishing Feature = Fail

14 06 2012

So here I am, trying to figure out how to create a page template. Of course SharePoint doesn’t like you to save things as templates if you have the publishing feature turned on ( i knew why, but the momentary laps in judgement due to my add, made me forget). So what do I do? Like a total noob, i go and disable publshing feature.
No Suup forrr JU! – soup nazi.
Errors all over the place. So naturally I said oops and tried to re enable it. It doesn’t scream at me.
But alas, the New Page Button is gone from the site actions menu.
Minor inconvenience i guess…but no it isn’t. There is more. I navigate to the Pages library to confirm its still there and it is. So i decide to create a new page and it does. But when i try to check it in i get:
-Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page.- And a bunch of red /.

Panic starts to set it.

But then I remembered something Yoda once said. Ok there are many things Yoda said that apply here, but none rang more true than:

May the Force be with you.

Powershell is a life saver. I did a quick search on syntax and ran these very commands:

PS C:\Users\spfarmadmin>Disable-spfeature Publishing -url http://yoursite/subsite -force

PS C:\Users\spfarmadmin> Enable-spfeature Publishing -url http://yoursite/subsite -force

 

Everything is back to normal. New Page button is back.

Now if i can only -force myself to stop doing stupid things in SharePoint, I would be set.

But then you guys wouldn’t have anything to read about.

Allrightythen.

Peace

Nando

 





Emails To SP libraries getting stuck in Drop Folder.

16 03 2012

Sharepoint 2010 has Amazing capabilities. One of them is the ability to email document libraries. It is very easy to setup.
I have had email enabled libraries running for almost a year, and then suddenly it stopped working. No warnings, nothing.
Emails where getting sent to the Drop folder, but they stayed there, going nowhere.
I was baffled. I tried everything.
IIS reset, new smpt server, rebooting, restarting timer service, etc.
I started digging and came up with these steps that WORK!

1.First on the CA Incoming Email settings I “had” to select Advanced Mode and enter the location of the drop folder.

2. You will have to run stsadm.exe -o enumservices to get the exact full name for the Incoming Email service to list in the next step.

3. Then after that they had to stop my Incoming Email Service manually at the command prompt. They ran stsadm.exe -o -provisionservice -action start -servicetype “Name of your incoming mail service,Version, Culture, Publickeytoken ” Mine was “Microsoft.Sharepoint.Administration.SPIncomingEmailSerivce, Microsoft.Sharepoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce11e9429c” NOTE THIS ALL HAS TO BE IN QUOTES WHEN YOU RUN STSADM COMMAND.

4. And Finally the all important IISRESET.

I still don’t know why it stopped working in the first place.
I will say this is mighty fishy.
make sure your timer service account has R/W permissions to the drop folder too. But other than that, this worked for me.

Hope it works for you.

peace out nando.





Document Center and Content Organizer

17 02 2012

One of SharePoint 2010’s hidden gems is the combo document center and content organizer.
By default the Document Center has a nifty Upload Document Button, but it goes to the standard document library. You can change that and point it to the Drop Off LIbrary that is produced when you enable the Content Organizer.

All you have to do is change some javascript. Here is how:

Edit the welcome page from Site Actions, and then click on the “Upload a Document” button. You will see this is actually just a content editor web part, so from the ribbon, under “Editing Tools” / “Format Text” click the HTML drop-down and then “Edit HTML Source”.

Replace the reference to the “Documents” library with “DropOffLibrary” i.e.:

<div><button onclick=”javascript:OpenNewFormUrl(‘DropOffLibrary/Forms/upload.aspx’);return false;” type=”submit”><nobr><img alt=”Upload a Document” src=”/_layouts/Images/uploaddoc.png”/> <span>Upload a Document</span></nobr></button> </div>

Save or stop editing the page and your done! The “Upload a Document” button will now default to uploading document to the Drop Off Library!