The Standard View of your list is being displayed because your browser does not support running ActiveX controls


SCENARIO:

When we open a Datasheet view in SharePoint, it displays it in Standard view with the error “The Standard View of your list is being displayed because your browser does not support running ActiveX controls.” as shown below.

Error

SOLUTION – 1:

  • In Internet Explorer, click on settings(Gear wheel symbol) and select Compatibility View settingsCompatibility view
  • Check “Display Intranet sites in Compatibility view” and hit close button

Compatibility settings

  • Refresh the Datasheet view with error to see the magic 😛

SOLUTION – 2:

NOTE: To apply this solution, close all the open windows and programs except IE.

  • In Internet Explorer, click on settings(Gear wheel symbol) and select Internet Options
  • Click on Advanced tab and hit Reset Button

Reset

  • Now, open the datasheet view with error.
  • If it does not work, restart the system after resetting IE and open the datasheet view to see it working!

 

 

Advertisements

PART 2 : Coding in InfoPath


For better understanding, please read PART 1 before proceeding further.

SCENARIO – Course Registration form

Course registration form contains four fields: Employee ID, Course Name, Course start  Date(Mandatory) and Course End Date(Mandatory)

course Registration Form

Let’s try to write code for

  • Validation on Employee Id text box to accept only numbers and must be of 6 digits
  • Validation on course name on button click
  • Submit the data and Switch to thank you page once validation is completed
  • Exit the application

Validation on Employee Id text box to accept only numbers and must be 6 digits:

Points to Note:

  • Validation message is shown only when Employee ID is edited for validating Event. If Employee ID is left blank, InfoPath throws the error, “An unhandled exception has occurred in the Form’s code” on submit button click.
  • Suppose validation is not applied under ValueChange condition (if (e.Operation == XmlOperation.ValueChange)), message dialog box will be shown once the form is loaded. Hence, do not use message dialog box for validating event as screen tip is already shown via the line e.ReportError(e.Site, true, “Please enter 6 digits”). Only if dialog box is necessary, use the condition to check on value change.
  • You may ask me, why should I apply in validating event and then check on value change rather than directly checking on changed event as shown below
public void EmployeeID_Changed(object sender, XmlEventArgs e)
{
 System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^[0-9]{6}$");
XPathNavigator xpn = this.MainDataSource.CreateNavigator();
string fiels1 = xpn.SelectSingleNode("/my:myFields/my:EmployeeID", this.NamespaceManager).Value;
if (!reg.IsMatch(fields1))
    {
         MessageBox.Show("Please enter 6 digits", "system message", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

Yes, it depends on your requirement. Validating event is used for Validation that shows red dotted line when the condition is not met and changed event is triggered on value change.

public void EmployeeID_Validating(object sender, XmlValidatingEventArgs e)
{
  //Validate on value change
  if (e.Operation == XmlOperation.ValueChange)
   {
      //Regular expression to check for 6 digit number
     System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^[0-9]{6}$");
     XPathNavigator xpn = this.MainDataSource.CreateNavigator();
     string fields1 = xpn.SelectSingleNode("/my:myFields/my:EmployeeID", this.NamespaceManager).Value;
     if (!reg.IsMatch(fields1)) //if regular expression does not match
      {
           e.ReportError(e.Site, true, "Please enter 6 digits");
           MessageBox.Show("Please enter 6 digits","system message",MessageBoxButtons.OK,MessageBoxIcon.Warning);
      }
  }
}

Validation message

Validation on course name on button click

//Validating if course name is blank on Submit button click
public void CTRL6_5_Clicked(object sender, ClickedEventArgs e)
{
  XPathNavigator xpn = this.MainDataSource.CreateNavigator();
  string course = xpn.SelectSingleNode("/my:myFields/my:CourseName",this.NamespaceManager).Value;
//checking if course name is empty using the length of the text
  if (course.Length == 0)
  MessageBox.Show("Please enter the course name");
}

Course Name error

You may also apply all the conditions in button click based on your requirement.

public void CTRL6_5_Clicked(object sender, ClickedEventArgs e)
{
  XPathNavigator xpn = this.MainDataSource.CreateNavigator();
  string course = xpn.SelectSingleNode("/my:myFields/my:CourseName",this.NamespaceManager).Value;
  string EmpID = xpn.SelectSingleNode("/my:myFields/my:EmployeeID", this.NamespaceManager).Value;
  System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^[0-9]{6}$"); 
  if (course.Length == 0)
       MessageBox.Show("Please enter the course name");
else if (!reg.IsMatch(EmpID))
        MessageBox.Show("Please enter 6 digits for Employee ID");  
else
    {
         DataConnection subconn = DataConnections["SharePoint Library Submit"];
       subconn.Execute();
        this.ViewInfos.SwitchView("Thank you");
     }
}

To validate on default submit, please write in FormEvents_Submit handler.

public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
XPathNavigator xpn = this.MainDataSource.CreateNavigator();
string course = xpn.SelectSingleNode("/my:myFields/my:CourseName", this.NamespaceManager).Value;
if (course.Length == 0)
{
 e.CancelableArgs.Message = "Please enter the course name";
 e.CancelableArgs.Cancel = true;
}
else
{
DataConnection subconn = DataConnections["SharePoint Library Submit"];
subconn.Execute();
e.CancelableArgs.Message = "The form was submitted successfully";
e.CancelableArgs.Cancel = false;
this.ViewInfos.SwitchView("Thank you");
}
}

Submit the data and Switch to thank you page once validation is completed

public void CTRL6_5_Clicked(object sender, ClickedEventArgs e)
{
XPathNavigator xpn = this.MainDataSource.CreateNavigator();
string course = xpn.SelectSingleNode("/my:myFields/my:CourseName",this.NamespaceManager).Value;
if (course.Length == 0)
MessageBox.Show("Please enter the course name");
else
{
DataConnection subconn = DataConnections["SharePoint Library Submit"];
subconn.Execute();
this.ViewInfos.SwitchView("Thank you");
}
}

Thank you Form

Exit the application on button click

//Exits the InfoPath application
public void CTRL1_9_Clicked(object sender, ClickedEventArgs e)
{
System.Environment.Exit(0);
}

code:

namespace Form1
{
public partial class FormCode
{
//All the events are initialized in internal startup automaticallypublic void InternalStartup()
{
 ((ButtonEvent)EventManager.ControlEvents["CTRL6_5"]).Clicked += new ClickedEventHandler(CTRL6_5_Clicked);
 EventManager.XmlEvents["/my:myFields/my:EmployeeID"].Validating += new XmlValidatingEventHandler(EmployeeID_Validating);
 EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);
 ((ButtonEvent)EventManager.ControlEvents["CTRL1_9"]).Clicked += new ClickedEventHandler(CTRL1_9_Clicked);
}

public void CTRL6_5_Clicked(object sender, ClickedEventArgs e)
{
XPathNavigator xpn = this.MainDataSource.CreateNavigator();
string course = xpn.SelectSingleNode("/my:myFields/my:CourseName",this.NamespaceManager).Value;
if (course.Length == 0)
MessageBox.Show("Please enter the course name");
else
{
DataConnection subconn = DataConnections["SharePoint Library Submit"];
subconn.Execute();
this.ViewInfos.SwitchView("Thank you");
}
}
public void EmployeeID_Validating(object sender, XmlValidatingEventArgs e)
{
if (e.Operation == XmlOperation.ValueChange)
{
 System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^[0-9]{6}$");
XPathNavigator xpn = this.MainDataSource.CreateNavigator();
string fiels1 = xpn.SelectSingleNode("/my:myFields/my:EmployeeID", this.NamespaceManager).Value;
if (!reg.IsMatch(fiels1))
{
 e.ReportError(e.Site, true, "Please enter 6 digits");
MessageBox.Show("Please enter 6 digits","system message",MessageBoxButtons.OK,MessageBoxIcon.Hand);
}
}
}

public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
//code for default submit data connection
}
public void CTRL1_9_Clicked(object sender, ClickedEventArgs e)
{
 System.Environment.Exit(0);
}
}
}

PART 1 – Coding in InfoPath


Hi! I am back with an article on InfoPath again. When someone says, you are an InfoPath expert, I say with sad face “No, I do not know about InfoPath Code behind and Digital Signatures”. No more worries on InfoPath Code behind. Thanks to my lead who introduced me to the world of InfoPath code behind.

Before going through the steps for code behind , make a note that coding can be done only in (InfoPath)Form library and not in List forms. Let us see how to create code behind file in InfoPath.

CREATING CODE BEHIND FILE:

  • Click on File tab -> Form Options(Advanced form options). In Form Options dialog box, click on Programming on left and choose the form template code language as shown below

(or)

  •  Go to Developer tab, click on Language and select the language/Change Language

  • Click on Code Editor(located next to Language in Developer tab) to see the FormCode.cs file(code behind file)
  • To write code for a button click, right click on the button ->Button Properties…->Edit form Code

Microsoft Visual Studio Tools for Applications opens as shown below

  • To validate a field or to set some action when the field’s value is changed, use the Validating event/Changed event in Programming  in fields pane or in Control Events section in developer tab

Control Events

So far, we have seen how to add code in InfoPath. Now, let us see the basic syntax/code

InfoPath is a xml file where all the fields are saved as xml nodes. To select or navigate to the nodes, XPathNavigator is used.

To get a field value in InfoPath, syntax goes as:

XPathNavigator xpn = this.MainDataSource.CreateNavigator();
string fn = xpn.SelectSingleNode(“XPATH OF THE FIELD“, this.NamespaceManager).Value;

To set a field value in InfoPath, syntax is

XPathNavigator xpn = this.MainDataSource.CreateNavigator();
XPathNavigator temp = xpn.SelectSingleNode(“XPATH OF THE FIELD, this.NamespaceManager); temp.SetValue(“Hello Sathiya”);

If you notice the above syntax, the first argument of SelectSingleNode is xpath of a field. To find the xpath of a field:

  • Go to Fields pane, click on down arrow dropdown of a field and select Copy Xpath as depicted below

To query or submit data connection, syntax is

DataConnection submitConn = DataConnections[“DATA CONNECTION NAME“];
submitConn.Execute();

To switch among the views, syntax is:

this.ViewInfos.SwitchView(“Thank you”);

 

With these basics, we will try to do magic 😛 in InfoPath form in the upcoming article 🙂

This file cannot be saved because some properties are missing or invalid


SCENARIO:

Editing a word document in SharePoint and saving it, throws the below error

Doc Properties Message

The error clearly states that required or mandatory column is not filled. When we check the properties by clicking “Go to Document Properties”, we see the core and mandatory column, Author as blank but they were filled already. Though we fill and save it back in word document properties, it becomes blank.

 

ROOT CAUSE:

Before uploading this document in sharepoint, author has inspected the document and removed the document properties and personal information as shown below

 

SOLUTION:

Click on File->Options to see Word Options dialog box. In the dialog box, select Trust center on left and click Trust center Settings button located under Microsoft Word Trust Center

Click on Privacy options and uncheck “Remove Personal information from file properties on save as shown below

Hit OK button and try to save the document.  Yayy! The error is  vanished.

InfoPath Preview to the rescue


In this post, let’s see about Preview option in InfoPath. It is not always recommended or necessary to publish the changes in order to verify it. To verify the changes made in InfoPath, use the preview option.

Preview for New forms:

Let us assume you are designing a new form and you want to verify then and there. Instead of publishing the changes every time, use the below steps:

  • Click on Home tab in InfoPath ribbon (if the current tab is not Home)
  • Click on Preview in Form section as shown below

Preview for new forms

Preview for Existing forms:

What if you are making an enhancement to the exiting form and would like to know how it behaves for already submitted form. Please follow the below steps to verify the behavior:

  • Go to the form library, select the submitted form and click on Download a copy in the ribbon as shown below

Download a copy

  • Go to InfoPath Design form and click on File->Form Options(Advanced Form Options)

Form Options

  • In Form options, click on Preview, browse the downloaded form under Sample data and click ok

Preview for Existing forms

  • Click on Home tab->Preview in Form section to see the changes in submitted form
  • If you have assigned User roles to the InfoPath form, you can change the user role to preview the submitted form as depicted below

Preview using different user roles

Error: Access Denied in approving an item


SCENARIO:

There is a InfoPath form library with unique permission set for each item(form) using “Replace permission” action in SharePoint Designer Workflow. When an item is created, an email is sent to the Approver with Contribute permission set by the workflow. If approver opens it, it shows access denied message.

ROOT CAUSE:

Check if InfoPath form library has the below library configurations in Versioning Settings:

  • Require content approval for submitted items – Yes
  • Who should see draft items in this document library – Only users who can approve items (and the author of the item)

SOLUTION:

Here are the possible solutions you can implement based on your scenario.

  1. If Content approval is not required, change it to “No” to avoid the above scenario
  2. If content approval is required, then approver can approve bulk items to allow others to see and edit the item
  3. If you do not wish to make any change in content approval, then you can change the Draft item Security(Who can see Draft Items) to Only users who can edit items
  4. If you do not wish to change the Content approval as well as Draft Item security, then you must change the permission assigned by the workflow to provide Approve access. This will work only for the items that will be created thereafter but for existing items, permission should be granted manually or using script

 

No item exists. It may have been deleted or removed by another user


In this article, let us see one of the scenario for which the error is shown as “No item exists at {item url}. It may have been deleted or removed by another user”

SCENARIO:

You have a SharePoint list customized in InfoPath for course registration where whenever user registers for a course, an email with item url is sent to the approver for approval. Once the approver clicks on the link in email, the below message is shown.

No Item exists error

 

Cause:

  • Go to List settings->Advanced settings
  • Check if item-level permissions is set as “Read items that were created by the user” for Read access and “create items and edit items that were created by the user” for create and edit access
  • This setup in item level permission indicates that only users can see and edit the items created by them

Solution:

  • Item level permission applies to users with Contribute or Edit access. So, to see and edit other’s item(override item level permission), the approvers should be given Design or Full Control Permission.
  • Another solution is to reset the item level permission configurations to default and use other ways of restricting access to items such as Replace permission using SharePoint designer workflow, SharePoint view filter for CreatedBy is equal to [Me]