Monday, April 13, 2015

CREATING MASTER-DETAILS RECORDS WITH REPEATING SECTION IN NINTEX FORMS

Forms that have data in a relation of one to many or with master-details can be created using Nintex Forms plus Nintex Workflow. An example of this would be an order form that includes product details such as name, unit price, quantity, taxes and total price as well as  order date, billing and shipping options, and you need to submit both parts together by clicking one submit or save button.

With Nintex Forms, you can build the master part (the order in our example) as you would any other form, using the drag and drop controls, then connect them to the right column on your list, or just keeping them unconnected if you want some of them to be just on the form and not part of the list data. The details part (the products) can be formatted on the form using the Repeating Section control, where you only design how one row should look. Here is a simple example of a repeating section with the product name and the quantity:


As I mentioned above, you can connect your controls to list columns, but for the controls inside the repeating section you cannot connect them to list columns. Instead, you can only connect the repeating section as whole to a multi-line plain text column. The data will be saved as XML in this column like this:

In 2012, Vadim Tabakman posted a very good blog article about Parsing Repeating Section Data where he is reading the repeating section data without creating an extra column for the XML. He parses the XML in a user defined action – UDA - then uses the loop workflow action to query each item inside the repeating section using an incremental index. Vadim’s post includes an example form, workflow and even the UDA. In the comments, his blog followers mentioned that using the loop workflow action is taking too much time to execute. This is true because Nintex has a farm level option named “Safe Looping” which is on by default. Safe looping simply adds delay actions to your workflow at publishing time in certain places like change state and loop. Read more about it in another post written by Vadim on November 2012. Vadim suggested to me through Nintex support that using a "Foreach" action will solve the delay issue, because Nintex does not add the delay inside the Foreach action. Imagine submitting an order with 30 products using the loop action. It would take more than 2 hours to create the order related products in the second list, while it would only take a second using the Foreach action.

Adding to the same concept, I found this post by Erik Abderhalden about Best Practices with Repeating Sections in Nintex Forms, which has some useful information you may need to know. But in his example he is creating a separate column in the main list to hold the repeating section XML while you already have it in a hidden column named DataForm on the list which has the repeating section XML encoded. 

By the way, you can access any un-connected filed on the form from the workflow by querying this hidden column if you don’t want to have a separate column for it. The same, you can have the repeating section not connected to a column and be able to use the Foreach action instead of the Loop action. Here is what that workflow looks like:


As you can see, I am using a UDA to get a collection of XML items to use in the Foreach action, and I am recommending using it as it will keep your main workflow smaller and reduce variables.  Remember, you already need to create a lot of variables to handle the details part. Here is my UDA:


Get the encoded repeating section XML using the Query XML action, then decode it and add it to a collection variable. Instead of the “Log in History List” action, add your logic to create or update the items in the products list.

You can download a sample workflow and the user defined action plus the details of each action from the links below. So I am not going to go into details for each step, as I think the downloadable screens and the other blog posts mentioned earlier have enough information. If not, please feel free to post your question in the comments below.

Conclusion:

Repeating Section in Nintex Forms is a very useful control. Dealing with parsing its data from the workflow is not hard once you know how, and one way to get the information is searching online. And if you post a question on Nintex Connect or send it to Nintex support, they will answer you in a reasonable time frame.

Friday, February 27, 2015

Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID

When you try to debug a SharePoint App from Visual Studio you may receive this error: "Error occurred in deployment step 'Install app for SharePoint': The provided App differs from another App with the same version and product ID" which means that your app is still on SharePoint somehow even if you can't see it in the Site Contents page.

To solve the issue you can check one or all of these steps:

  1. Make sure that the App is removed from the site it is installed to. Go to Site Contents and find if it is there in an error state waiting for you to click on "Try again" to be deleted.
  2. Remove the App from the site collection recycle bin if it is there (by default it will stay in the recycle bin for 93 days). This will move it to the Second-Stage recycle bin if you clicked on "Empty Recycle Bin" and will delete it if you selected the app and clicked on "Delete". (in all cases you will only find the App in the site collection recycle bin but the web site created for the App will be in the Second-Stage recycle bin, so every time you remove an App there will be one part in the first recycle bin and another part in the Second-Stage recycle bin, and restoring any of these parts will restore the other part).
  3. Remove the App from the Second-Stage recycle bin.
  4. If you still can't upload your App, repeat step 2 & 3 :)
  5. If after step #4 you can't upload your App, go to the AppManifest.xml and change the Version (or the ProductID if you are still in the development)
You can get more information about Recycle Bin here : https://support.office.com/en-us/article/Manage-the-Recycle-Bin-of-a-SharePoint-Online-site-collection-5fa924ee-16d7-487b-9a0a-021b9062d14b?ui=en-US&rs=en-US&ad=US


Thursday, July 24, 2014

Passed exam 70-486 : Developing ASP.NET MVC Web Applications

I passed exam 70-486: Developing ASP.NET MVC Web Applications two weeks ago, "al 7amd lellah", I am now preparing for Exam 70-487: Developing Windows Azure and Web Services.

ASP.NET Web API - Part 1

Two years ago (Aug 2012), my college Jonathan Kyle and I represented ASP.NET Web API at the ASP.NET Atlanta User Group, then we wrote a blog that never posted, and as I am reading again in the web services and the updates in the Web API I think I can start by posting the blog as the concept  is still the same, then write about the new features.

The first post of the series is written by Jonathan, and here it is:

Introduction:

Everything now became connected together in a way that it became so difficult to say that we have this set of communication languages or communication formats for any conversation including the question or the answer. It is also difficult to let the person you are communicating with just answer your question without adding more details unless you asked him for, and if you need more details do you want it as a text, diagram or a map or whatever? This is why there is always a need for a standard way to communicate, standard way to ask and a standard way to answer, and it is very important to have this communication method very simple to be able to communicate with anyone who has the minimum level or understanding. This is why ASP.NET WEB API is here.


What is ASP.NET Web API

A multi-tier application development platform built on top of the .NET Framework for building and consuming HTTP services that can reach a broad range of clients.  It incorporates the best from WCF Web API and the best from ASP.NET MVC.
.NET and HTTP Services Timeline

Microsoft has arrived at the ASP.NET Web API after several evolutions of web technologies, and applying the lessons learned along the way.

  • 2002: ASP.NET ASMX Services
  • 2006: .NET 3 – WCF Services (SOAP + WS-* Stateful)
  • 2007: .NET 3.5 – WCF WebHttpBinding (first attempt)
  • 2009: WCF - REST Starter Kit (separate package)
  • 2010: .NET 4/WCF - REST Starter Kit + HTTP Services
  • 2012: Merged into ASP.NET MVC Framework called “Web API”


Feature Highlights

  • Modern HTTP programming model: HTTP capable application / client such as a web browser, ajax, or HttpClient.
  • Full support for ASP.NET Routing:  Uses the HTTP method to determine which action is performed by the web application.
  • Content negotiation and custom formatters: Supports automatically converting objects from the server into the data format requested by the client such as JSON and XML.
  • Model binding and validation: Supports automatically converting and validating data from the client into objects on the server.
  • Filters and Query composition: Easily support OData and query syntax.
  • Easy to unit test: Uses MVC pattern makes an application that can have actions tested in isolation from other bits of code.
  • Improved Inversion of Control (IoC) via DependencyResolver: Uses application configuration to automatically find dependent resources for an action.
  • Code-based configuration:  Application can be configured programmatically, not just by application configuration.
  • Flexible Hosting: fully supports Self Host, IIS and Windows Azure.

Why ASP.NET Web API


ASP.NET Web API is the ideal platform for building RESTful application on the .NET Framework.  It is a pattern which enables an application to publish an entity as a Uniform Resource Identifier (URI), typically classified as a Uniform Resource Locator (URL) that is accessible using the HTTP protocol.
The application level protocol (HTTP method) such as GET, PUT, POST, and DELETE specifies the operation that is performed with the entity.  Metadata describing a message is described by the header information built into the HTTP protocol, for example:

  • The body of a message meets the criteria specified in the header such as a description of an entity in a specific format (XML, JSON, etc).
  • Entity contained in the body can be hypermedia (links to other resources)
  • A response message may be a cached response that a proxy server can use as a response without ever passing the request to a server.

ASP.NET Web API uses the elegant MVC infrastructure, allowing the utilization of the HTTP protocol with the minimum amount of coding, and enables the application developer to focus on the business specific application implementation.

Although ASP.NET Web API is an improvement over REST API in WCF by not needing the plumbing complexity, WCF may still be better for messaging and duplex communication, such as using MSMQ or TCP.

Wednesday, May 15, 2013

VPN establishment capability from a remote desktop is disabled - Hyper-V

I have a virtual machine created on Hyper-V in windows 8, I noticed that when I connect to the machine using the remote desktop connection I can't establish a VPN connection using Cisco AnyConnect  and I receive this error: "VPN establishment capability from a remote desktop is disabled". But I can establish the connection if connected to the VM using the Hyper-v Manager.

Update: Check this post by devhammer: http://devhammer.net/cisco-anyconnect-and-hyper-v---connect-to-a-vpn-from-inside-a-vm-session

Wednesday, April 17, 2013

0.1 + 0.2 != 0.3


After more than 13 years experience with JavaScript I just discovered that:

0.1 + 0.2 != 0.3

read this article to understand: http://yuiblog.com/blog/2009/03/10/when-you-cant-count-on-your-numbers/

but :

(0.1 * 10 + 0.2 * 10) / 10 = 0.3

Tuesday, November 27, 2012

Convert your VMW drives VMDK to Hyper-V drives VHD

After installing Windows 8 and using Hyper-V I searched for a tool to convert my VMW disks to be used on Hyper-V. This tool is amazing and it just take few minutes to convert a disk with Windows2008R2/SQLServer/SharePoint2010/VisualStudio2010

http://vmtoolkit.com/blogs/announcements/archive/2006/11/20/vmdk-to-vhd-converter-available.aspx

Tuesday, November 20, 2012

Special offer for Exam 70-480: Developing in HTML5 with JavaScript and CSS3

There is a special offer from Microsoft as a jump start and voucher code for free exam for 70-480: Developing in HTML5 with JavaScript and CSS3, it is one of the Windows 8 development series.

Get it from there:
http://www.microsoftvirtualacademy.com/tracks/developing-html5-apps-jump-start

I passed this exam two weeks ago, "al 7amd lellah"

Get Web Part Properties for a page with PowerShell script

It happens when you have a problem with a webpart in one of your SharePoint environments in need to debug to see what are the properties of this webpart, this PowerShell script can help:


#Add-PSSnapin Microsoft.SharePoint.PowerShell

$SiteUrl = "http://www.yoursite.com"
$pageURL = "Pages/default.aspx"

$site = New-Object Microsoft.SharePoint.SPSite($SiteUrl)
$psite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($site)
$web = Get-SPWeb $SiteUrl
$pweb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)

$wpm = $web.GetLimitedWebPartManager($pageURL, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)

#List all the web parts
$wpm.WebParts | ft

#Get the details of the first web part
$wp = $wpm.WebParts[0]
$wp


SharePoint 2013 on Windows 2012 Server - Admin Intro

Just installed SharePoint 2013 Server on Windows 2012 Server and SQL 2012 Server inside Hyper-V machine on Windows 8 :)


Just wanted to share with you the screen as this will be my first blog post on SharePoint 2013, and just to show you something useful, this is the performance screen for my server till the moment:


My machine is Dell Latitude E6520 with 8 GB RAM

Wednesday, October 10, 2012

Active File in Solution Explorer - Visual Studio 2010 & Windows 8


Today I Installed Visual Studio 2010 on Windows 8 beside Visual Studio 2012, and what I noticed is that the active file - the one I am editing now - is not highlighted in the Solution Explorer, and this was really annoying as moving between files dose not showing me which file in the solution hierarchicy I am editing. And I though it is a bug in the beginning but I figured out that it is an option:

From "Tools" go to "Options" then "Projects and Solutions",  and under "General" change"Track active item in Solution Explorer" to checked.

I don't know why there is an option like this, why a user may need to edit a file and that file is not highlighted in the solution explorer

Thursday, May 24, 2012

Convert Anonymous Type into key/value Array

The answer in this link is very simple and great:

http://stackoverflow.com/questions/3481923/in-c-sharp-convert-anonymous-type-into-key-value-array


var a = new { data1 = "test1", data2 = "sam", data3 = "bob" };
var type = a.GetType();
var props = type.GetProperties();
var pairs = props.Select(x => x.Name + "=" + x.GetValue(a, null)).ToArray();
var result = string.Join("&", pairs);

Wednesday, March 21, 2012

Custom ViewState in MVC

Just in case anyone want to build his own ViewState here is an example:

The model is serialized JSON (you can write JavaScript to read any information even if it is not rendered in a separate control) and then deserialized.

For security (if your model contains information that should not displayed in the HTML source, you can encrypt it then decrypt it with the post back), also compression will be helpful for smaller response/request. (I think this is why MVC is better in performance, because NO ViewState :) )

Also in the code after getting the data from the ViewState, you can compare it with the data retrieved from the model to know which field is updated, you can then call a method accordingly (the same as TextBox1_Changed(...., ....) in ASP.NET forms), this can be done as well from JavaScript by injecting in the hidden field using jQuery whenever the value of any control is updated.

In the form add a hidden field that will hold the viewstate, plus all your other controls.

You can also add in the ViewState a bool value indicating the IsPostBack, and use this value in the form or the code.

Tuesday, December 20, 2011

PowerShell script to configure your SharePoint Services

Check this link if you want to configure your SharePoint 2010 services from PowerShell script http://todd-carter.com/post/2010/04/26/The-Wizard-Likes-His-GUIDs.aspx

The good thing here is that documenting these scripts is much more easier than documenting step by step with images to do it from the central admin.

Thursday, December 15, 2011

PerformancePoint error after adding new servers to the farm

I was adding two front end servers to a SharePoint farm this week, and I got an error in all the dashboards when the load balancer redirect to these two servers:

PerformancePoint Services could not connect to the specified data source. Verify that either the current user or Unattended Service Account has read permissions to the data source, depending on your security configuration. Also verify that all required connection information is provided and correct.

System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)

at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)

at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)

at System.Data.SqlClient.SqlConnection.Open()

at System.Data.SqlClient.SqlConnection.Open()

at Microsoft.PerformancePoint.Scorecards.DataSourceProviders.SqlTabularDataSourceProvider.GetConnection()

at Microsoft.PerformancePoint.Scorecards.DataSourceProviders.SqlTabularDataSourceProvider.GetConnection()

at Microsoft.PerformancePoint.Scorecards.DataSourceProviders.SqlTabularDataSourceProvider.GetConnection()

at Microsoft.PerformancePoint.Scorecards.DataSourceProviders.SqlTabularDataSourceProvider.GetDataSetInternal(Int32 maximumRows)

PerformancePoint Services error code 201.

And finally I found the solution here http://social.msdn.microsoft.com/forums/en-US/sqldataaccess/thread/c488cf76-2515-440f-b3f8-9cfad689c5b6/

I’m just posting the URL in my blog to make sure that I will find it again as it helped me a lot, it has all the possible places to check.

Also you have to see if the servers are configured for Kerberos delegation if you have it, and the claims to windows token service account has the right permission on the servers as per this document http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23176, and check the user groups on the servers to make sure that the service accounts are in the right place. you can also check the binding in the ISS and make sure that the required applications are running. Also check the web.config and the e-mail settings in iis (6)

Tuesday, November 22, 2011

Get Public Key External Tool

Another good external tool command is to get the public key token of your assembly.

Title: Get Public Key
Command: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe
Arguments: -Tp "$(TargetPath)"
Use Output Window: Yes

Wednesday, October 19, 2011

Know which process to debug


With each new machine or new setup I'm searching for this information to know which w3wp process is mine to debug, so I'm adding it here in my blog to find it easily next time and to be available to everyone who search for the same information.

go to Tools from the upper menu, then External tool and add a new command:


The ID displayed in the output menu beside your application pool name is yours, and this is the process ID that you can select when you want to debug your application.



Tuesday, May 10, 2011

Moving SPWeb inside the SPSSite in SharePoint 2010 using PowerShell

This script will move the site “ToBeMoved” to be under “ToBeMovedTo” and change its Url and Title to “Moved”



$w = Get-SPWeb 'http://servername/ToBeMoved'
$w.Url
$w.ServerRelativeUrl = '/ToBeMovedTo/Moved'
$W.Title = 'Moved'
$w.Update()
$w.Url


Please note that it will take some time to be updated.