Sample: Create custom Design workflow for Infopath forms in a SharePoint list
Scenario: When a user Added an item to Transactions list, the State field should change to submitted and only his manager can able to Approve that item. After approval the State field should change to Approved.
So i would like to open the SharePoint List Forms in infopath and create custom views for New Form and Edit Form.
In Custom New Form i will add a button Submit. I will add rules to update the State field and Submitting data to the List.Then i will create a workflow in sharepoint designer that will trigger when ever an item is added.In the workflow i will create an action to get the current user's Manager from User profiles and update Approver field in the list.
And on Edit Formi will add Approve button with rules to update State field.
Let us start...........
Create a list with Custom List template and name it as Transactions. Add Columns
Permit Number - Single Line of Text
Permit Date - Date Time
Country of Import - Dropdown List
Comodity - Dropdown List
Approver- Person or Group
State-Single Line of Text
Now click on List from List Tools
Click on Customize Form option to edit SharePoint List Items in Infopath
A form will be opened like above. Add a Button control From Home-->Controls and name it as Submit.
Now click on the Submit Button and select Manage Rules. Add rule when button clicked
Here the condition for the rule is None-Rule runs when button clicked
Now Add actions:
- Set State field to Submitted
- Submit using a data connection
- Close the form No prompt
Setting State field:
Enter Submitted in the value field.
Submit data to a sharepoint List:
Here i have selected the Main Data connection to submit the data.
Next thing was close the form with no prompt.
Create workflow to get Current user's Manager:
From Workflow settings of the list--> select--. create a workflow in sharepoint deisgner.
Enter desired workflow name in Name field. click on OK
Add Action--> Lookup Manager of a User.
Set this user in the action to User who created current Item.
Next add another action, Set field in Current Item. Here select field as Approver. And for Value -->
select Workflow lookup for a user and click Add.
Click OK. So when ever an item is added State field will be updated to Submitted and Approver field is filled with current user's Manager.
Let us cretae a new item and check the Item in Transactions List.
Now create a New view and name it as Edit view. Add Approve button.
Condition: We need to show this button to Approver only.
Add rule--> New--> Formatting. In the condition
Hide button, if the current user is not the Approver
AccountId is not equal to concat(substring-before(AccountId, "\"), "\", UserName()).
See there is no Approve Button. Why becaues we have logged in as DEPTLUSER1 ans see the Approver name as DEPTLUSER2.
See the Approve button appears because we have loged in with Approvers credntials DEPTLUSER2. Click on Approve. The State field will gets updated.
Thats it folks.
Reference:
If you got any doubts refer the below link to set the condition
Comments
Post a Comment