Hi,
Sorry for the late response. If you don't have that data connection configured yet, kindly create one by using via SOAP web service:
- Enter the URL for your Active Directory:
http://%3cyoursharepointsite%3e/_vti_bin/UserProfileService.asmx?WSDL - Select the operation GetUserProfileByName.
- Click next until you reach the last page of the data connection wizard.
- Uncheck the check box that automatically retrieves data when form is opened.
- Click Finish and close the data connection window.
- Under the Data tab of InfoPath, click Form Load.
- Add a rule called Get Department.
- For the first action of that rule, add a logic to populate the AccountName query field of the GetUserProfileByName data connection using the function userName() - you might need to use a subsring function to remove unnecessary data.
- Add an action that queries GetUserProfileByName.
- Using this Active Directory, you may now extract the curent user's data from the items returned.
- To get the current Department, add a field called Department to your form.
- Populate that field with the the Value node from the data connection and filter this data by setting the Name = Department.
I have attached a sample form you may use for reference. Note that some conditions or scenarios might not be applicable for you due to the difference of our SharePoint environments, but the approach should work.
Please download the form (right click > save target to a local folder > right click xsn > open in design mode), then check the set of rules under Form Load.
Hope this helps.