InfoPath Hyplerlink opens as Read Only

Recently ran into an issue where you place a hyperlink on a InfoPath form, user clicks the link, the item opens as read-only, no Edit Document option.

The fix is to do a regedit to allow for editing of the document.

example

[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Internet]
“OpenDocumentsReadWriteWhileBrowsing”=dword:00000001

in the Common\Internet folder you would create a new DWORD value OpenDocumentsReadWriteWhileBrowsing and assign it a Value of 1.

http://support.microsoft.com/kb/870853

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

Trying to use an Event Handler in SharePoint 2007 my test user was seeing this error:

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

The error was being triggered by an ItemUpdated or ItemAdded event.

fix:

Public Overrides Sub ItemUpdated(ByVal properties As SPItemEventProperties)
SPSecurity.RunWithElevatedPrivileges(AddressOf mCode)
End Sub

Private Sub mCode()
Dim eFire As hEventFiring = New hEventFiring
Using spsSite As SPSite = New SPSite(sPi.WebUrl)
Using spwWeb As SPWeb = spsSite.OpenWeb

Dim iSPl As SPListItem = spwWeb.Lists(sPi.ListId).GetItemById(sPi.ListItem.ID)

Try

eFire.dEventFire()
Dim roleAssig As New SPRoleAssignment(spwWeb.SiteGroups(mGroup))
roleAssig.RoleDefinitionBindings.Add(spwWeb.RoleDefinitions(“Contribute”))

If iSPl.HasUniqueRoleAssignments = False Then
iSPl.BreakRoleInheritance(True)
End If

For Each spra As SPRoleAssignment In iSPl.RoleAssignments
spra.RoleDefinitionBindings.RemoveAll()
spra.Update()
Next

iSPl.RoleAssignments.Add(roleAssig)
iSPl(“CommentField”) = mGroup
iSPl.Update()
eFire.eEventFire()

Catch ex As Exception
iSPl(“CommentField”) = ex.Message.ToString
iSPl.Update()
Finally
End Try
End Using
End Using
End Sub

Class hEventFiring
Inherits SPItemEventReceiver

Public Sub dEventFire()
Me.DisableEventFiring()
End Sub

Public Sub eEventFire()
Me.EnableEventFiring()
End Sub

End Class

————

What I’m doing:

1. Use RunWithElevatedPrivileges to call the code that updates the item.

2. Disable event firing with eFire.dEventFire

3. Break role inheritance using BreakRoleInheritance

4. Assign permissions using iSPl.RoleAssignments.Add(roleAssig)

5. Enable event firing eFire.eEventFire.

The key to this working is Dim iSPl As SPListItem = spwWeb.Lists(sPi.ListId).GetItemById(sPi.ListItem.ID)

Lookup field, Value does not fall within the expected range

Using a Workflow to update a Lookup field in a Library in SharePoint I ran into this error:

Value does not fall within the expected range

I had no issue obtaining the value of a value from the Lookup field.

Dim sString As New SPFieldLookupValue(DirectCast(wfP.Item(“Field-R”), String))
sString= sString.LookupValue

BUT, what I failed to pay attention to was the hyphen in the field name.

Using the U2U CAML Query Builder I discovered my problem.

The real field name was Field_x002d_L

wfP.Item(“Field_x002d_L”) = New SPFieldLookupValue(1, “Value”)

…. Make sure you are updating the correct field name.

code:

spLibItem.Item(sField) = New SPFieldLookupValue(sValueID, sValue)

workflow to get the value of Lookup field

In Visual Studio 2008.

I was trying to get the value of Lookup field in a Document Library and would see a result like this:

sLookup = workflowProperties.Item(“FieldName”).ToString

but it returns: 9;#FieldValue

This is how I went about fixing the string (if there is a better way, please tell me!)

sLookup = Right(workflowProperties.Item(“FieldName”).ToString, Len(workflowProperties.Item(“FieldName”).ToString) – InStr(workflowProperties.Item(“FieldName”).ToString, “#”))

Update the Assigned To field using a Visual Studio 2008 Workflow

After spending way too many hours messing with this, I got it to work. I was trying to update the Assigned To in a Form Library (also works in a Document Library) using a Workflow in Visual Studio 2008. SharePoint being SharePoint, nothing is ever easy.

In the VS I created a Sequential Workflow. Then I added a Code activity (codeActivity1) to the design. After that, double click codeActivity1 in the design window.

Create the Public variable wfP:

Public wfP As SPWorkflowActivationProperties = New Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties

Then add the following code to your codeActivity1 module.

Dim site As SPWeb = New SPSite(wfP.WebUrl).OpenWeb()

Dim list As SPList = site.Lists(wfP.List.Title)

Dim listItem As SPListItem = wfP.Item

listItem(“Assigned To”) = site.Groups(“gLeads”)

listItem.Update()

It should look like this when you are done:

Private Sub codeMoveToLead_ExecuteCode(ByVal sender As System.Object, ByVal e As System.EventArgs)

Dim site As SPWeb = New SPSite(wfP.WebUrl).OpenWeb()

Dim list As SPList = site.Lists(wfP.List.Title)

Dim listItem As SPListItem = wfP.Item

listItem(“Assigned To”) = site.Groups(“gLeads”)

listItem.Update()

End Sub

Trying to set the .AssignedTo never worked for me.

CopyTo in Visual Studio

I’m a little rusty on writing code and this is something that I spent way too much time messing with.

Dim destURL As String = “http://sitename/OtherLibrary/”
workflowProperties.Item.CopyTo(destURL & workflowProperties.Item.Name)

It’s not as simple as saying copy from/to. The CopyTo wants a URL, file name, and file extension.

If you receive this error:

Cannot create an item at the requested destination.  Verify that the folder exists and that you have permission to edit in it.

Start by checking your syntax.

Unable to open workflow in Designer 2007

Recently tried a STSADM export / import to move a site to a new collection.  After the STSADM import I tried to open a workflow using SharePoint Designer and received the following error.

The server could not complete your request. Contact your internet service provider or Web server administrator to make sure that the server has the Frontpage Server Extensions or SharePoint Services installed.

The fix was to recycle or restart the SharePoint server.

Parameter name: errorData SharePoint 2010

When creating my SharePoint 2010 sandbox farm I wasn’t able to get past connecting to the database server.  This is the error I was seeing:

An error has occurred while validating the configuration settings.  An exception of type System.ArgumentNullException was thrown.  Additional exception information: The errorData argument cannot be null or zero length.  Parameter name: errorData

I logged into my SQL Server 2008 R2 VM and updated the Start Mode of SQL Agent and SQL Serve Browser to Automatic.

What / Where / How

Start –> All Programs –>SQL Server XXX –>Configuration Tools –> SQL Server Configuration Manager

After it opens select SQL Server Services, right click on SQL Server Browser, select properties, click on Service, then set Start Mode to Automatic.  Repeat these steps on SQL Server Agent service.

After doing this I restarted the server.

——– edit

if you are having trouble finding your SQL Server, Server Name try looking here:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLSERVER

SNI10.0 — LastConnect

There you will find the name of your SQL Server