Sharepoint 2013 Anonymous list send email workflow


Continuing with the limitation of anonymous access in association to SharePoint lists, it turns out there is another one!

When anonymous users add a new list item and we want to send an email, we will think of either 'Alerts' or 'Custom Workflow'. Using alert will work fine if the email is redirected to SP users.
However if the email wants to go to certain email addresses or the person submitting the item (through email field for example) then 'Custom Workflow' is the way to go.

So I opened SPD 2013 and created some reusable workflows with 'To' set to Association parameter and the Email field on the list item. Also the send email is contained in the Impersonation step.
Workflow is then published and associated to the list. I set the trigger to run the workflow when new item is created.

Testing the workflow while logged in works fine - however when adding a new item anonymously, the workflow is just waiting and never triggered. Having read other people experiencing the same issues, the solution is to create an ItemAdded event receiver to run the workflow using elevated permission.

In my case I have a few lists with their own content types.

After activating the feature, you don't need the triggers set on your workflow settings anymore.


SharePoint 2013 anonymous access add attachments to list item


Sometimes you want to enable anonymous access to be able to add a list item but at the same time attaching some documents.

After good few hours playing around trying to make this work, turns out that we can achieve this functionality. The trick is to use RunWithElevatedPrivileges method for the file upload. We also want the file upload functionality to be available on the NewForm.aspx as it wouldn't make sense to put it in other forms as any user would be able to upload files to other records.

The result will be something like this:

When it is saved, the user is redirected to the display form:

The close button then will take the user back to the homepage (or any page you desire)

The steps:
1. Create an ascx control to host your file upload control in your project. 

Put the below script in the ascx as well (credit to this post):
The code behind:
2. Create custom form template. You have to put the ascx in the CONTROLTEMPLATES folder of the 15 hive. Then find ListForm rendering template from the DefaultTemplates.ascx and copy to the custom template ascx. Register the control from step 1 and modify the following table:

3. The last step is to add a FeatureActivated receiver in order to set the template name (I use content type for my lists). Also your code needs to break list inheritance and specify AddListItems permission for the anonymous users.


Sharepoint 2013 visual webpart ascx not updated when updating solution

Hi all,

I recently came across this issue. My visual webpart ascx file does not get updated when updating wsp solution. Same issue as this post or this post.

I have checked my ascx inside the wsp file and also looked at the g.cs file generated by SharePoint. Both were fine.

It used to be working fine when I updated my webpart files. This issue happens after I merged the code from another branch and built the solution. I suspect this has something to do with it.

I tried changing my ascx file so that it regenerates the g.cs file - but still doesn't work.

I then rolled back my code (before merging), updated the code manually and rebuilt the solution. This time it works! my webpart is updated again.

So, there is a bug with moving webpart code around projects (as indicated in the first post above) or merging the code (in my case). I hope this issue will get resolved as it will be annoying to not being able to merge some visual webpart codes between branches.

Update: this post might be the workaround - haven't tried it yet.


CRM 2011 - set or assign record owner


Just a recap of how to set the record owner or assign a new owner through the sdk.

When creating a record, you don't need to use AssignRequest. Simply set the OwnerId and call SaveChanges of your context.

But if the record already exists, then you must use AssignRequest to assign the record to the new owner.


Sharepoint 2013 List View Webpart Anonymous Access denied error You do not have permission to perform this action or access this resource


If you happen to get the access denied for anonymous users on a webpart (in my case list view) and you already gave anonymous permission on the list, you are not alone.

Apparently this is happening especially when you use custom xsl for the display of the items. Luckily I came across this thread that shows the trick to avoid this bug.

You just need another xsl that imports your custom xsl. In the webpart Xsl link you will then use this other xsl instead.

There you go. I tried this and I'm not getting the access denied anymore.