Thursday, February 28, 2013

How to create Content Organizer rule in SharePoint 2010


In this article we will be seeing how to create Content Organizer rule in SharePoint 2010.

SharePoint 2010 introduced a new feature called Content Organizer

Activate the feature Content Organizer:
  • Content Organizer is a site feature. 
  • Go to Site Actions => Site Settings => site Actions =>Manage site features.
  • Activate the feature Content Organizer.
1.gif 

Once you have activated this feature, you will see two options "Content Organizer Settings" and "Content Organizer Rules" in Site Actions => Site Settings => Site Administration.

2.gif

A new document library "Drop Off Library" also will be created where you will be adding the documents. Those documents will be moved to the target document library based on the Content Organizer rule.

3.gif

And also a new content type will be created for Content Organizer rule as shown in the following

4.gif

Content Organizer rule:
  • Go to Site Actions => Site Settings => Site Administration => Content Organizer Rules.
  • Enter the Rule Name.
  • In the Submission's Content Type section select the Content type Group and Type.

    5.gif
  • Set the Property-based conditions for the rule.

    6.gif
  • Select the Target location where you want to save the document based on the rule conditions.
  • Click OK.
  • A new rule will be created successfully.

    7.gif
Add a document to the Drop Off Library, and enter the title as Finance.

8.gif

If the rule condition is satisfied (in my case if "Title is equal to Finance") a message will pop up as shown in the following

9.gif
                    
and the document will be saved in the target library.

10.gif 

If the condition is not satisfied a message will pop up as shown in the following

11.gif
                   
And the document will be added to the drop off library.

Add rules for performing other actions in Infopath



In addition to validation and formatting rules, you can also add rules to form templates to perform other actions, such as switch views, set a field value, or query or submit to a data connection. For example, you could design a form so that the data users enter into it is automatically saved to SharePoint, without clicking Submit, or to switch from one view to another when a button is clicked.
These rules can be activated by changes to a form field, clicking a button, inserting of a repeating section or row in a repeating table, or the opening or submission of a form. These rules check for conditions based upon the data in the form, the user role, or the value of a field. They can also run without any conditions needing to be set.
You can also add multiple actions for each rule. For example, you can add a rule to a button that submits the data that was entered, and then switches to a view that displays a message to confirm that the data was submitted.
In this article

Action rule types and examples


Show a message

You can add a rule that opens a dialog box if a certain condition in the form is met. For example, in an expense report form if the user enters a value that exceeds a specific amount a message can appear. Show a message actions are only supported in InfoPath Filler forms.

Show the value of a field or formula

This action enables you to add a rule to display the value in a field or a calculation based on the values of different fields on the form. For example, a user can be advised that the arrival date in a hotel expense must be before the departure date by using the dates entered by the user. Show the value of a field or formula actions are only supported in InfoPath Filler forms.

Switch views

Views can be switched when a button is clicked. This enables users to navigate through two or more views by clicking back or next. You can also add a rule to switch the view when the form is opened. For example, views can be switched based on the role that is associated with the user that opens the form. Switch views actions are only available on buttons and Form Load.

Set a field’s value

Using a rule to set the value of a field allows you to dynamically change values in a form. For example, in an expense tracking form where users enter an expense item and the amount of the expense, a Total field can track the total of entered expenses. Instead of having users manually enter the total of all expenses, the set a field’s value action can automatically set the value of the Total field.

Query for data

The query for data action enables you to query an external data source for information. For example, you can add a query for data action that initiates a query to a database to retrieve employee information when a user enters his or her employee number in a form.

Submit data

A submit data action rule submits all of the data in a form. For example, using the submit data action, you can add a rule to a form template for a permit application that submits the data in the form to both a Web service and a database when the user clicks a Submit button on the form.

Open a new form to fill out

Open a new form to fill out enables you to add a rule that opens a new copy of a form that is based on this form template or another form template. For example, you can add this rule to a form template for a permit application to do the following: If the value in an expenses field exceeds a fixed amount, the rule opens a new form that requires an itemized entry of expenses. Open a new form to fill out actions are only supported in InfoPath Filler forms.

Close the form

The close the form action enables you to add a rule that closes the form when a specified event occurs on the form. For example, you can add a rule that closes a form after the user submits the form and the external data source confirms that the form was successfully submitted. Close the form actions are only available on buttons.

Send data to Web Part

You can enable your form to send data to SharePoint Web parts by adding the send data to Web part action. When an InfoPath Web browser form is hosted inside the InfoPath form Web part on a SharePoint page and a connection has been configured with another Web part, this rule initiates sending the data in the InfoPath form to the connected Web part. For this rule action to function correctly, fields in the form must be promoted as Web part connection parameters. In SharePoint list forms, all fields are automatically promoted as connection parameters.

Sign signature line

The sign signature line action enables you to add a rule that, when triggered, opens an indicated signature line control for the user to sign. For example, if you have a signature line control on the form, and you add the sign signature line action to the submit button, then when the user clicks the submit button they are asked to sign the signature line control.

Data Connections

If you add an action rule to query data, submit data, or submit data to a Web part, then it is best to already have the desired data connection in place before the rule is added. For more information on external data connections, see Data connections overview.

Add an action rule


Use the Add Rule button

Included, pre-defined rules can be added by clicking Add Rule.
  1. Click the control that you want to add the action to.
  2. On the Home tab, in the Rules group, click Add Rule.
Add rules for performing other actions
  1. In the If column, click the type of condition that the rule must meet, such as Is Blank.
  2. In the Actions column, click an action, such as Submit Data. Depending on the condition selected, additional information might be requested.
  3. Do the following, depending on the type of action you are adding from the Rule Details window:
Add rules for performing other actions
  • Show a message
  • In the Message field, type the text for the message, and then click OK.
  • Show the value of a field or formula
  1. Either enter the expression in the Expression box, or click Function Add rules for performing other actions next to the Expression box to build your expression, and then click OK.
 NOTE    For more information regarding formulas, see Add functions and formulas.
  • Switch views
  • In the Rule Details dialog box, click the view that the user will switch to when the action is initiated from the View box.
  • Set a field’s value
  1. Click Field Add rules for performing other actions next to the Field box.
  2. Click the field to select it.
  3. Click OK.
  4. In the Value box, type the value, or click Function Add rules for performing other actions next to it to enter a formula.
 NOTE    For more information regarding formulas, see Add functions and formulas.
  • Query for data
  • Click a receive data connection from the Data connection field or click Add to add a new data connection.
 NOTE    For more information regarding data connections, see Data connections overview.
  • Submit data
  • Click the submit data connection from the Data connection field or click Add to add a new data connection.
 NOTE    For more information regarding data connections, see Data connections overview.
  • Open a new form to fill out
  • Enter the template ID or the location of the form template in the Form Template ID or Location box, and then click OK.
  • Close the form
  • Click OK if this is a Web browser form or, if this is a Filler form, you can optionally select the If changes have not been saved, prompt the user to save check box to prompt users to save the form before it is closed.
  • Send data to a Web Part
  1. Click Property Promotion to select the fields that should be promoted as Web part connection parameters.
  2. Click Add next to the list of SharePoint Web part connection parameters to display the Select a Field or Group dialog box.
  3. Click a field.
  4. In the Parameter name box, enter a name for the parameter.
  5. Click OK.
  6. Repeat steps 2 through 5 to promote additional fields.
  • Sign signature line
 IMPORTANT    Before adding a sign signature line rule, make sure that you have added a signature line control to the form so that there is something for the rule to sign.
  1. Under Sign the first signature line where, in the list, click the method of indicating which signature line from the form should be signed.
Add rules for performing other actions
  1. In the is equal to box, enter the criteria or click Function Add rules for performing other actions to use a function for the criteria.
  2. Indicate whether or not a default signature image should be used and whether or not the signature line is in the host document, and then click OK.
 NOTE    For more information regarding digital signatures, see Digital Signatures in InfoPath 2010.
  1. Click the Don’t run remaining rules if the condition of this rule is met check box if you want to stop processing additional rules.

Use the Rules task pane

Do the following to add an action rule from the Rules task pane:
  1. Click the control that you want to add an action rule to.
  2. If the Rules task pane is not visible, then, on the Home tab, in the Rules group, click Manage Rules.
Add rules for performing other actions
  1. Click New.
Add rules for performing other actions
  1. Click Action.
  2. In the Details for text box, enter a name for the rule.
Add rules for performing other actions
  1. Under Condition, click None.
  2. Select the correct options as follows:
  • If the condition for your rule is based on a field:
  1. Click a field or click Select a field or group.
  2. Click the operator, such as is equal to.
  3. Enter the criteria for the operator.
  • If the condition for your rule is based on an expression:
  1. Click The expression.
  2. Enter the expression.
 NOTE    For more information, see Add functions and formulas.
Add rules for performing other actions
  1. Click And to add another condition and repeat step 7 or click OK when done adding conditions.
 NOTE    After adding a second condition, the And button is replaced with a box. Leave and selected if both the first and each subsequent condition needs to be true for the data validation to be applied. Otherwise, if only one of the conditions should be true for the data validation to be applied, click or.
  1. On the Rules task pane, click Add, and then click the type of action rule that you want to add.
  2. Do the following, depending on the type of action you are adding.
  • Show a message
  • In the Message field, type the text for the message, and then click OK.
  • Show the value of a field or formula
  • Enter the desired expression in the Expression box, or click Function Add rules for performing other actions next to the Expression box to build your expression, and then click OK.
 NOTE    For more information, see Add functions and formulas.
  • Switch views
  • In the Rule Details dialog box, click the view that the user will switch to when the action is initiated from the View box.
  • Set a field’s value
  1. Next to the Field box, click Field Add rules for performing other actions.
  2. Click the desired field to select it.
  3. Click OK.
  4. Type the desired value in the Value box or click Function Add rules for performing other actions to enter a formula.
 NOTE    For more information regarding formulas, see Add functions and formulas.
  • Query for data
  • Click the appropriate receive data connection from the Data connection field or click Add to add a new data connection.
 NOTE    For more information regarding data connections, see Data connections overview.
  • Submit data
  • Click the appropriate submit data connection from the Data connection field or click Add to add a new data connection.
 NOTE    For more information regarding data connections, see Data connections overview.
  • Open a new form to fill out
  • Enter the template ID or the location of the form template in the Form Template ID or Location box, and then click OK.
  • Close the form
  • Click OK if this is a Web form or, if this is a Filler form, click the If changes have not been saved, prompt the user to save check box to prompt users to save the form before it is closed.
  • Send data to a Web Part
  1. Click Property Promotion to select the fields that should be promoted as Web part connection parameters.
  2. Next to the list of SharePoint Web part connection parameters, click Add to display the Select a Field or Group dialog box.
  3. Click the field.
  4. Enter a name for the parameter in the Parameter name box.
  5. Click OK.
  6. Repeat steps 2 through 5 to promote additional fields.
  • Sign signature line
 NOTE    Before adding a sign signature line rule, make sure that you have added a signature line control the form so that there is something for the rule to sign.
  1. Under Sign the first signature line where, in the list, click the method of indicating which signature line from the form should be signed.
  2. In the is equal to box, enter the criteria or click Function Add rules for performing other actions to use a function for the criteria.
  3. Indicate whether or not a default signature image should be used and whether or not the signature line is in the host document, and then click OK.
 NOTE    For more information regarding digital signatures, see Digital Signatures in InfoPath 2010.
  1. Click the Don’t run remaining rules if the condition of this rule is met check box if you want to stop processing additional rules after the selected rule is processed.

Setting parameters for querying or submitting data

The submit data and query for data actions activates the data connection to either send or receive data. In the case of query for data, you can specify what data is queried by adding a set a field’s value action rule to set the value of the desired query field.

Data entry patterns

Action rules can be based on the text pattern that a user enters into a text field. For example, if you want to collect a ZIP/Postal code, then you might want to make sure the user enters it in the correct format. Likewise, if you want a user to enter an email address, then you can match their input to a pattern that includes some text, an @symbol, a domain, and a domain suffix such as .com.
To do this, when building the condition, in the Operator list, click Matches Pattern, then click Select a pattern. This displays the Data Entry Pattern dialog box where you can choose from several pre-defined, standard patterns. If none of these patterns meets your needs, you can use a custom pattern.

Advanced condition scenarios

The following are advanced scenarios that you can use when setting the condition of an action rule.
  • Base a rule on an expression
An expression is a set of values, fields or groups, functions, and operators. Use an expression to set the value of a field in such scenarios as automatically including the current date on a form, or adding the cost of items entered into an expense report to get the total.
  1. Click The expression.
  2. Enter the expression into the second box.
 NOTE    For more information regarding functions and formulas, see Add functions and formulas.
  • Base a rule on a set of signable data
If a form requires a digital signature, you might want to disable the submit button if the form has not been signed. Or, for example, you might want to activate the submit data action after a user adds a digital signature. This condition is only supported in InfoPath Filler forms.
  1. Click Select set of signable data.
  2. In the Select Set of Signable Data dialog box, click the set of signable data, and then click OK.
  3. Click the desired condition from the second box, and then click any necessary criteria from the third box.
 NOTE    For more information regarding digital signatures, see Digital Signatures in InfoPath 2010.
  • Base a rule on a user’s role
If your form has multiple views, such as an administrator view and a read-only view, then you can create a form load rule that switches to a view based on the current user’s role.
  1. Click User’s current role.
  2. Click the operator, such as is equal to.
  3. Click the role or Manage roles to manage user roles.

Introduction to InfoPath rules


Rules allow you to control the behavior of a form by performing actions that take place based on conditions within the form, or events that take place when filling out a form. The behavior that you can control by using rules in a form includes automatically displaying a message inside of a dialog box, setting a field value, querying or submitting data to SharePoint or a database, or switching views. These rules can be triggered by the user changing the value in a control, clicking a button, or opening or submitting the form. They can also be triggered based on conditions that are present when the form is opened, such as the user role or based on a value that is queried from a data source.

Types of rules

The following three types of rules are available:
  • Validation    Validation rules are used to indicate an error when the user enters an invalid value into a control. For example, a validation rule on a text box can confirm that a user enters a valid e-mail address. For more information regarding validation rules, see Add rules for data validation.
  • Formatting    Formatting rules are used to apply text formatting and background shading to controls when a condition has been met. They can also be used to hide or disable a control. For example, a formatting rule can hide or display follow-up questions based upon a user’s answer to a preceding question, instead of including instructions for the user to “skip to step X.” For more information regarding formatting rules, see Add rules for conditional formatting.
  • Actions    Actions are the most varied type of rule. Use these to switch views, set values in other fields, submit the form, or query for data. Actions are available depending on what you are trying to apply them to and whether you are building a browser form or an InfoPath Filler form. For more information regarding rules that perform other actions, see Add rules for performing other actions.


Create rules

There are two ways to add rules to your form. On Home or Control Properties tabs, in the Rules group, you can use either the Add Rule menu or click Manage Rules to open the Rules task pane.
On the Home tab, the Add Rule menu is the fastest and easiest way to add rules to your form. For example, it only takes four steps to add a rule to your form to validate dates.
  1. Select the date picker control.
  2. Click Add Rule.
  3. Click Is in the Future.
  4. Click Show Validation Error.
Now, when a user enters a date that is in the future, an error message appears. You can customize this automatically-created rule using the Rules task pane. For example, you can make changes to the ScreenTip box to give the user a more specific error message.


Manage rules that are applied to controls

All rules are managed through the Rules task pane. Only the rules that are applied to the selected control appear. For example, if you have a text control with a rule applied to it that verifies user input is a valid e-mail address, only that rule appears in the Rules task pane when you select that text control.
Introduction to rules
You can use the Rules task pane to add, delete, or copy rules. For example, if your team gauges workload and risk on a sliding scale from 1 to 10, you can create a rule that flags a value of more than 7 by shading the field red, and then copy the rule to both the Team Workload and Team Risk fields on a form.
The following are some of the actions available from the Rules task pane:
  • To create a new rule, click New.
  • To delete a rule, select the rule, and then click Delete.
  • To copy a rule or all rules that are applied to a control, click Copy Rule or Copy All Rules.
  • To paste a rule that you have copied from another control, click Paste Rule.


Set rules for opening or submitting the form

Additional rules can be configured to run when the form is first loaded or when a user submits the form. To add form load or form submit rules, on the Data tab, in the Rules group, click either Form Load to set a rule that runs when the form is loaded or click Form Submit to set a rule for when the user submits the form. Clicking either Form Load or Form Submit changes what appears in the Rules task pane, in the same way selecting a control does. When you click Form Load, the rules that run when the form is loaded appear in the Rules task pane, where you can add or manage them as you require.
To enable the Form Submit button, do the following:
  1. On the Data tab, in the Submit Form group, click Submit Options.
  2. Select the Allow users to submit this form check box, and then click Perform custom action using Rules.
  3. Click OK.
 IMPORTANT    When the Rules task pane appears, create a new rule that runs when the form is submitted. If this is not done immediately, you must re-enable the Form Submit button. After a rule is added, the Form Submitbutton remains enabled, and then you can switch between different rule contexts.


Rule Inspector (view all rules in a form template)

Use the Rule Inspector dialog box to view all rules and calculated default values that are in use on a form. To open the Rule Inspector dialog, on the Data tab, in the Rules group, click Rule Inspector.
Introduction to rules
The Rule Inspector dialog box displays fields that have rules associated with them and how these rules are related to other fields in the form template. This also helps you to determine if there is a problem with the rules on the form and to resolve problems.
 NOTE    The Rules Inspector dialog box doesn’t display formatting rules.
When you open the Rule Inspector dialog box, four types of rules appear:
  • Validation
  • Calculated Default Values
  • Actions
  • Programming
Within each of these sections, fields that have rules attached appear, in addition to the rules for each field. For each rule, conditions and corresponding actions appear.
If you click on a field, the Rule Inspector displays the rules that are associated with that field, either directly or indirectly, in the following categories:
  • Rules that depend on this field or group    This category includes any rules that use the value in the field or group. For example, you can create a rule that runs when a user opens this form and the value in field1 is within a certain range.
  • Rules that are triggered by a change in this field or group    This category includes any rules that are activated if the value in the field or group changes. For example, you can create a rule that adds seven days to a user-entered date and automatically displays the new date in another control.
  • Rules that may change this field or group    This category includes any rules that can change the value of this field or group. For example, you can create a rule that sets the value of this field based on the value of another field in the form template.