How can I get the current user's Manager with Web Request Control (Forms)


Userlevel 4
Badge +10

Hi Folks,

I just got Nintex Forms and I need to figure out how to use a Web Request Control to get User Profile information. As a test case, I would like to add the control to my form configured as label or text to show the current user's manager. Can anyone demonstrate how that is done?

Thanks and Best Regards,

Patrick


13 replies

Badge +16

You can use an expression and in the for builder query the user profile?

Userlevel 4
Badge +10

Thanks for the reply Cassy Freeman,

I am new at forms. Can you screenshot what you are talking about?

Thanks!

Badge +16

Hi

Sorry about that, I was replying off of my phone so I couldn't shoot you any screenshots...

This is the control you are looking for in your toolbox on nintex forms:  Calculated Value.PNG

Drag it to where you want it on the form and double click it to configure.  Use the formula builder button to access named controls and the inline functions such as userProfileLookup.

In the below image, we are pulling the manager of the person entered into the "RequestedBy" named control.  We are then doing a userProfileLookup of that returned value to get the display name for the manager:

userProfileLookupFormulaBuilder.PNG

with the formula userProfileLookup(userProfileLookup(RequestedBy,"Manager"),"PreferredName")

if you wanted just the manager you would use:

userProfileLookup(RequestedBy, "Manager")

and if you don't want to look for the manager of the person chosen inside a control, you could replace RequestedBy with the Current User under the common tab in the formula builder.

Hope that helps...  happy.png

Userlevel 4
Badge +10

Hi Cassy,

We have actually had success with the userProfileLookup function. What I am trying to do is "figure out how to use a Web Request Control to get User Profile information" so that I can apply it to more complex solutions. I am hopeful that if I can make it work for something as simple as pre-populating a users profile data, I will be able to build on that knowledge and do things like automatically provision a new user based on roles that they are assigned from an Access Web App.

Do you have an idea on how to get the Web Request working? Incidentally, once I have gotten a handle on web requests, I will be digging into SQL Request controls. happy.png (Just incase you have expertise in that area...) happy.png

Thanks and Regards,

Patrick

Badge +16

Patrick Kelligan​ ah I got you...  sorry about that!  Unfortunately I cannot be much more help in this instance but watching with interest to the thread now.  Keep me posted with whatever you find please?

Userlevel 4
Badge +10

No problem and Thanks Cassy Freeman. Will do!

Userlevel 5
Badge +9

Hi Patrick,

I managed to perform what you'd like to do with SharePoint 2013 OnPrem.

Firstly, I created a calculated value named CurrentUserLoginName with the following formula (Current User is the reference that you can found in Common tab and replace is the reference that you can found in Runtime Functions tab):

     replace(replace(Current User,":","%3A"),"#","%23")

Here's how I configured the Web Request control on Nintex Forms:

  • Display format: Label
  • Service Url (Site URL is the reference that you can found in Common tab and CurrentUserLoginName is the reference to the calculated value control that you can found in Named Controls tab): Site URL/_api/sp.userprofiles.peoplemanager/getpropertiesfor(@v)?@v='CurrentUserLoginName'
  • Request method: GET
  • Authentication type: Windows authentication
  • Secure Store target application ID: myTargetAppID
  • XPath for display: //*[local-name()='Key' and .='Manager']/../*[local-name()='Value']

Tell me if you have any problems with this solution.

Hope it works on your environment

Userlevel 4
Badge +10

Hi Caroline,

Great Response. Here is what a straight "Current User" renders for me (no quotes):

"i:0e.t|adfs|myuserid@mydomain.com"

Does this impact what I should use in the replace function? What should the string look like when the replace is complete?

Thanks!

Patrick

Userlevel 5
Badge +9

it should look like this for the following login name :

i:05:t|adfs with roles|user@domain.com

i%3A05%3At%7Cadfs+with+roles%7Cuser%40domain.com

You should replace @ by %40 and I think that's all.

I didn't managed to replace | by %7C but it worked for me if this character is in the url.

You can type the url in the browser (Chrome) and you should get a response or an error if something is wrong.

Hope it works

Userlevel 4
Badge +10

Hi Caroline Jung

I tried using the following: replace(replace(replace(Current User,":","%3A"),"|","%7C"),"@","%40")

It returned this: %7Ci%7C%%7C3%7CA%7C0%7Ce%7C.%7Ct%7C|%7Ca%7Cd%7Cf%7Cs%7C|%7Ck%7Ce%7Cl%7Cl%7Ci%7Cg%7Ca%7Cn%7Cp%7C%40%7Cl%7Ce%7Ci%7Cd%7Co%7Cs%7C.%7Cc%7Co%7Cm%7C

What did I do wrong?

Userlevel 5
Badge +9

I have the same behaviour than you, that's why I didn't replace "|" by "%7C" and it works without this replacement.

You can try with the following : replace(replace(Current User,":","%3A"),"@","%40")

Userlevel 4
Badge +10

Hi Caroline,

It has been a while since I have had the time to dig back into this. Since our last contact on this, we have made some changes. My user account (current user) looks like this now: i:0#.w|leidos-corpkelliganp

We are trying to create what you describe above and are running into a road block. I am working wioth the farm administrators and I wanted to know what the configuration of "myTargetAppID" (your Secure Store target application ID) is. We have several configured. One that we have in place for the InfoPath service (just called "InfoPath" renders the following error in Test Request:

193628_pastedImage_8.png

It seems a different configuration on a different Secure Store target application ID renders a different error:

193629_pastedImage_9.png

Any thoughts?

Thanks!!

Userlevel 5
Badge +9

Hi Patrick,

Sorry for the delay.

Secure store is a bit tricky. I noticed that it works better with an Individual target application type.

Is it what you created?

Reply