Archive

Archive for the ‘SharePoint’ Category

Testing problems with SharePoint 365


I was trying to develop an Add-in on SharePoint online, the version that comes with Office365, after a long experience with SharePoint on premise.
The first thing I tried was the obvious HelloWorld in Vs2015:

specifying a hosted version:

then

Some changes to code, and immediately tried to launch with F5…error!:

error occurred in deployment step 'install sharepoint add-in' sideloading is not enabled

Ok, the story is : The site collection should be based on “Developer Site” template or you have to enable sideloading feature.
Sideloading apps is not secure.
The main reason for blocking sideloading by default on non-developer sites is the risk that faulty apps pose to their host.
Apps have the potential to damage site collections.
Then apps should be sideloaded only in dev/test environments, never in production.
Anyway is faster to immediately try our code, so the first thing is to download and install the SharePoint Online Management Shell.
Done this, we can download the PowerShell scripts from here.
These scripts must be changed in the initial part, where are provided url, user, password; you can press Return for the questions so are used the cabled values:

if ($siteurl -eq '') {
    $siteurl = 'https://yourtenant.sharepoint.com'
    $username = 'user@yourtenant.onmicrosoft.com'
    $password = ConvertTo-SecureString -String '<yourpwd>' -AsPlainText -Force
}

Launched from the SharePoint Online Powershell, another error….:

Error encountered when trying to enable SideLoading feature https://******.sharepoint.com : Exception calling "ExecuteQuery" with "0" argument(s): "For security reasons DTD is
prohibited in this XML document. To enable DTD processing set the DtdProcessing property on XmlReaderSettings to Parse and pass the settings into XmlReader.Create method."

I tried to launch in Powershell

set-ExecutionPolicy Unrestricted

But still the error, and probably is not requested: i was staring at the screen, thinking to return to my ancient job as plumber (yes.. when i was very young, MS-DOS was recently commissioned from IBM to Bill Gates while i was trying to make some money for the motorcycle).

After some searches i found the incredible solution: it seems that the “DTD is prohibited..” is related to a DNS problem in order to reach your tenant; so the solution is to use the Google DNS couple 8.8.8.8 8.8.4.4 in your pc network setting:

So, the Powershell activation was now running ok:

And magically , launching with F5:

Advertisements
Categories: Office365, SharePoint

Network path was not found error

I’ m working with networked computers from near 30 years, and with Microsoft networks from 20.

I still remember the old good times of Windows 3.11 (not For Workgroup) and the problems of a network between Win 3.11 and Windows 95 clients: there was no Internet, the network adapters were coming by floppy disks in the adapter box or by connecting to a remote BBS for the latest update.

It was the time of networking with Lantastic (i still remember the infamous “ding” sound when the network was clogged…) : so sometimes the best solution was a Novell Netware 286 dedicated server; but there was the problem in the client PCs , loading the Novell drivers chkdsk were erroneously reporting severe problems in the file system.

Now many problems are gone: i prepared a server with Windows 2012 Standard some months ago and i discovered that from the ASRock BIOS is possibile not only to download the requested drivers on a USB key (even if i found that if the USB key has no sufficient space the download apparently is anyway OK..) but if the server is connected to a working Internet connection is possible to require assistance to the producer, from the BIOS !

I was thinking to the same situation (network card unacknowledged) at the times when i was installing Windows NT 4.0 Workstation.

Now with the same server, reformatted and installed with Windows Server 2012 R2, no problem for the network card, no need for external download: Windows 2012 R2 has directly acknowledged the network card.

But there are still issues with Microsoft networking .. for example i installed an 2012 R2 as domain controller with address 192.168.0.2, the ADSL modem is 192.168.0.1 and in practice is the DNS.

Then i installed another server 192.168.0.4 dedicated to SharePoint 2013 (never install SharePoint on a domain controller) and the first thing is to join this server to the domain controller.

Tipically you go to Control Panel->System, change settings from workgroup to domain, write the domain name and click ok: after inserting when prompted the user “administrator” of the DC with the password .. a long wait … and then the error.

Ok, i’m primarily a developer so i don’t know very well some system arguments, but searching on Google i noticed that the error reported in the subject of this post is not so rare.

The solution is to set as DNS in the adapter property of the client not the ADSL modem address but the one of the DC : in my sample 192.168.0.2 instead of 192.168.0.1

Done this, the domain is joined without a long wait and the internet connection is working.

There are other possible issues to verify: in the adapter property verify if is activated

“Client for Microsoft Networks”


and the services “Remote Registry” and “TCP/IP NetBIOS Helper” are running on DC and server that you would join to the DC.

Conclusion: a little hint from the OS when you get this error?

Categories: SharePoint, Uncategorized

Remote Desktop for standard users in Windows 2012

By default is possible to connect to an Windows Server 2012 instance via remote desktop the the administrator user, in this case i’m working to a SharePoint 2013 server virtual machine (done with Vmware Workstation 10.1).

Normally for the administrator is sufficient to activate in the Advanced system properties (in the control Panel, for the System item) the remote desktop:


The administrator is already enabled to the remote desktop, but a user not in the Administrators group can be inserted here (as in figure) , in Active Directory insert him/her in the Remote Desktop Users group


and still when you try to connect to the server this is the result:


My solution to the issue perhaps is not the best but is working: launch the Windows 2012 Server Manager then in Tools menu choose “Local Security Policy”


Here select in “Local Policies” the “User Rights Assignment” item, and add here the user or group:


After this step the Remote Desktop is working for an not administrator user in Windows 2012 Server.

Categories: SharePoint, VmWare

SharePoint 2013 preview deployment guide

A free ebook at this address.

Categories: SharePoint

Book review: SharePoint 2010 Workflows in action

I have read this Manning book in order to achieve a better knowledge about workflows, and it was very useful.

The book is not recent, but it took a long time in order to follow in the spare time the examples.

Every type of workflow is well examined , with clear examples that i was able to follow and repeat , without using the downloadable book code.

I was buying the book as part of the MEAP program (Manning Early Access Program) which is useful because you access the book while is not still fully finished: this has some drawbacks (typos, an approssimative look) but when a technology is very “fresh” could be an serious advantage.

The book starts from an exam of the workflows type can you develop (using the out of the box workflows that you can add via browser, SharePoint Designer ,Visual Studio) with a clear explanation of what is available in SharePoint Foundation and what in the SharePoint Server edition.

In the book are developed some workflows starting from adding a workflow in a library tools (Chapter 2) using the settings page, then in Chapter 3 are examined the workflows done with SharePoint Designer, with an very useful example about a calendar: in this chapter are well explained the components of a workflow.

Chapter 4 is interesting , is about the relations between Workflows and task processing with useful examples about task assigning from a workflow.

Chapter 5 , about advanced workflows with Designer, reveals and well explains some very interesting concepts about security and the use of external data sources.

The use of Visio for workflows development is explained in Chapter 6: i was tempted to skip, but anyway how to have an diagram in your workflow page that shows the followed logic (with Visio Services) could be useful.

The Chapter 7 is about to develop workflow forms with Infopath: the example of to have a form containing a table for expenses with totals is interesting , even if not completed (the reader will review in Chapter 9 this example that will be finished with the calculations).

The Chapter 8 is about custom Visual Studio workflows, so it is very developer oriented and the first part ,where are explained the Activities that you could put in a workflow, is very valuable.

Here i have encountered some problems on the book code that i have explained in my previous post.

At the end of page 202 there is an invite to deploy solution, but before you should make the steps of page 203.

For a State Workflows is not so easy ,as the book depict, to have an State Workflow working with an OnWorkFlowItemChanged , for me is better to use an EventHandler and then from this launch the WorkFlow (without the OnWorkFlowItemChanged event management).

In Chapter 9 is interesting the part “Adding .NET code to an InfoPath form”, but the book doesn’t explain well that when you add code in a InfoPath form then (at least in my experiments) the Publishing by Quick Publish does not work (you get an error for InternalStartup routine) and you must publish by File->Publish->SharePoint Server and choose Administrator-Approved (then manage the upload in http://<server><port>/_admin/manageformtemplates.aspx); following this path for every successive update.

In every case i have noticed that using the InfoPath filler at runtime the events works correctly, in the browser the events are working only when you save and you don’t set the property Postback of the Amount control to “Always”.

The Chapter 10 is about the Tasks, more interesting is Chapter 11 on Custom activities and conditions: here is explained how to create your activities library with some useful tricks for the every day work.

Very interesting the section in Chapter 11 where is explained how to develop a .actions file, in order to have custom actions and conditions in the SharePoint Designer: i think that the samples could be more simple but is ok.

In the last Chapter 12 there are interesting hints for debugging and fault handlers, hints on versioning, and some samples on the workflow object model.

But the very interesting part in this chapter is on the Pluggable workflow services, that is how to communicate from a workflow with the external world (another database, for example).

Categories: Books, SharePoint

SharePoint Foundation 2013 preview

Categories: SharePoint

Conditional menu in SharePoint List

With Custom_AddListMenuItems we can create a custom item in the SharePoint menu for a list item, but sometimes this item must be created only for specific items, depending for example from a specific item value.

In this example we assume a List field named “Document Type” from a list named “Documental”, and we want to display a menu “Substitute” only for item with Document Type = “DOCUMENT”.

The problem is that we cannot directly read the item values of custom fields with GetAttributeFromItemTable , we can always traverse the page DOM with JQuery but is a bad idea : it is easy to change a column position.

The solution is to use the Lists.asmx sharepoint service called in synchronous mode, because in async the CamOpt calls are not working in the callback function.

So the code of the CEWP in the view page is

<script type="text/javascript">
    var strUrl;
    var strCtxHttpRoot;
    var strItemUrl;
    var objM;
    
    function Custom_AddListMenuItems(m, ctx) {
        var strID = GetAttributeFromItemTable(itemTable, "ItemId", "Id");
        strCtxHttpRoot = ctx.HttpRoot ;
        objM = m;
        var strSoap = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"><listName>Documental</listName><query><Query xmlns=""><Where><Eq><FieldRef Name="ID" /><Value Type="Counter">' + strID + '</Value></Eq></Where></Query></query><viewFields><ViewFields xmlns=""><FieldRef Name="Document_x0020_Type" /></ViewFields></viewFields></GetListItems></soap:Body></soap:Envelope>';
        $.ajax({
            url: strCtxHttpRoot + "/_vti_bin/lists.asmx",
            type: "POST",
            dataType: "xml",
            async: false,
            data: strSoap,
            complete: processResult,
            contentType: "text/xml; charset=\"utf-8\""
        });     
    }
    
    function processResult(xData, status) {   
        if (status == "success"){
            $(xData.responseXML).find("z\\:row").each(function() {
                var strDocType = $(this).attr("ows_Document_x0020_Type") ;
                if(strDocType == "DOCUMENT"){
                    var strImagePath = "/intranet/Media/UPDATEPAGEVARIATION.GIF";
                    var strID = GetAttributeFromItemTable(itemTable, "ItemId", "Id");
                    // Add menu item
                    CAMOpt(objM, "Substitute" , "callSubsts();" , strImagePath);
                    CAMSep(objM);
                    return false;                
                }
            });
        }
        else{
            window.document.getElementById("divSpin").style.display = 'none';
            if (xData.responseXML != undefined)
                window.alert(xData.responseXML.text);
            else
                window.alert("Error. call assistance: problem with Custom_AddListMenuItems verifying doctype if DOCUMENT.");            
        }
    }    
    
    function callSubsts(){
        //action
    }
</script>

Categories: SharePoint

Pages with data in SharePoint 2007 and ID as querystring

For complex tasks with data coming from various sources sometimes is required to create a custom page.

Tipically this is done from Site Actions->Create->Web Pages

Here we can create a Web Part Page , choosing the layout (with/without Header, Footer, 2 or more columns and so on) that will be saved in the Shared Documents document library of the current Site .

The same for the Basic Page, in practice a Web Part Page without a layout for 2 or more columns and no web parts zones.

For displaying data in our page we can read the produced code when we create a List / Document Library custom form for add or edit : basically it is used the SharePoint:SPDataSource so we can write

<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" 
style="margin-left:27pt;">selectcommand="<View></Query><ViewFields><FieldRef Name='Title'/><FieldRef Name='Document_x0020_Type'/></ViewFields></View>" id="spdatasource3">
style="margin-left:27pt;"><SelectParameters>
style="margin-left:54pt;"><asp:Parameter Name="ListID" DefaultValue="{FBCD7E0D-0697-4937-A42E-106DFA056E85}"/>
           </SelectParameters>              
</SharePoint:SPDataSource>

In order to obtain a “skeleton” for the SPDataSource we can create a Basic Page , place the cursor in the code view in SharePoint Designer and in the Data Source Library select “Insert Data Source Control”


Note that in SharePoint Designer 2007 could be necessary a switch to Design view and back to Code in order to have available the menu as in the figure.

By default is created this code

<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" selectcommand="&lt;View&gt;&lt;/View&gt;" id="spdatasource1">
    <SelectParameters>
        <asp:Parameter Name="ListID" DefaultValue="{FBCD7E0D-0697-4937-A42E-106DFA056E85}"/>
    </SelectParameters>
    <DeleteParameters>
        <asp:Parameter Name="ListID" DefaultValue="{FBCD7E0D-0697-4937-A42E-106DFA056E85}"/>
    </DeleteParameters>
    <UpdateParameters>
        <asp:Parameter Name="ListID" DefaultValue="{FBCD7E0D-0697-4937-A42E-106DFA056E85}"/>
    </UpdateParameters>
    <InsertParameters>
        <asp:Parameter Name="ListID" DefaultValue="{FBCD7E0D-0697-4937-A42E-106DFA056E85}"/>
    </InsertParameters>
</SharePoint:SPDataSource>

If we need to only display data the Delete Update Insert parameter sections can be deleted as in the previous code.

In the selectcommand we can specify a field list , filter conditions and so on; the better approach is to place in a page a ListViewWebPart, convert in XSLT and in the Designer make all changes: after we can read generated commands.

We can display data using the XSLT syntax or by the old mode (note the DataSourceID, the same of our SPDataSource ) :

<asp:FormView ID="ProductsFormView" DataSourceID="spdatasource3" AllowPaging="false" runat="server">
    <ItemTemplate>
      <table>
        <tr>
          <td align="right"><b>Title</b></td>
          <td><asp:Label id="lblTitle" runat="server" Text='<%# Eval("Title") %>' /></td>
        </tr>
      </table>                 
    </ItemTemplate>
</asp:FormView>  

If we need to display a single item is obvious to use the ID field which we have by default in every List / Document library, so we can write

<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" 
style="margin-left:27pt;">selectcommand="<View><Query><Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>{id}</Value></Eq></Where></Query><ViewFields><FieldRef Name='Title'/><FieldRef Name='Document_x0020_Type'/><FieldRef Name='ID'/></ViewFields></View>" id="spdatasource3">
style="margin-left:27pt;"><SelectParameters>
style="margin-left:54pt;"><asp:Parameter Name="ListID" DefaultValue="{FBCD7E0D-0697-4937-A42E-106DFA056E85}"/>
style="margin-left:54pt;"><asp:QueryStringParameter Name="id" QueryStringField="id"/> 
           </SelectParameters>              
</SharePoint:SPDataSource>

The field used for the filter must be present in the FieldRef list.

The ID field is a Counter type, and enclosed in {} we specify a parameter name that must be defined in the Select parameters.

Here we can do the mistake: we can be tempted to use for the QueryStringParameter a QueryStringField named “id” (or “ID”, but the casing is not important) as in the sample code but in this manner our code simply not work: we always get the Yellow Error Page that tell to us “No item exists…..may have been deleted or renamed by another user.” also we are sure that this “id” exists.

If we use another name for the parameter, as

<SharePoint:SPDataSource runat="server" DataSourceMode="List" UseInternalName="true" 
style="margin-left:27pt;">selectcommand="<View><Query><Where><Eq><FieldRef Name='ID'/><Value Type='Counter'>{baid}</Value></Eq></Where></Query><ViewFields><FieldRef Name='Title'/><FieldRef Name='Document_x0020_Type'/><FieldRef Name='ID'/></ViewFields></View>" id="spdatasource3">
style="margin-left:27pt;"><SelectParameters>
style="margin-left:54pt;"><asp:Parameter Name="ListID" DefaultValue="{FBCD7E0D-0697-4937-A42E-106DFA056E85}"/>
style="margin-left:54pt;"><asp:QueryStringParameter Name="baid" QueryStringField="baid"/> 
           </SelectParameters>              
</SharePoint:SPDataSource>

Our code works.

I have tried to insert a numeric field named “baid” (the same name of the querystring parameter) and still my code works, so it seems a specific problem related to the Counter field (“ID”).

From the other hand if we sort a ListViewWebPart we can notice that in the querystring are used the fieldnames as parameters, so i think that the better approach for a custom querystring is to avoid ID as name for sure (and in every case existing field names ) developing a naming scheme (with a particular prefix, for example) for custom querystring parameters.

Categories: SharePoint

Data Sources in Designer 2007

The CQWP has an alternative , to use a “Data Source Library” in SharePoint Designer.

At the upper right side of the Designer window there is a toolbox , where a tab is the “Data Source Library”.


Here we can click on “Connect to another library” and create a sort of ODBC connection with other site collections.

Ih this part is managed a connections library, where clicking Add is requested a Name and a Location.


The Location browsing ask an http address of a SharePoint web site


Done this,you have a named connection


And in the DataSourceLibrary you see a new folder with the lists and document libraries


Dragging a list / doc library in a WebPartZone (in the sharepoint page opened in Designer, on the link “Click to insert a web page”) the list / doc library is available for customizations (Filter, Sort,Columns to display…)


In the web page you have a List web part already transformed in XSLT


Categories: SharePoint