Initial form with checking if user exists


Badge +2

Hi,

I'd like to create initial form where manager must fill out form with initial data on behalf of user. First of all manager must check if user exist in AD/User Profile. This is very important because sometimes this form will be fill out when user doesn't exist. So using People picker it is checked if user exist. If exist all form/list fields are fill out with data from User Profile. If not manager must input data manually. I'd like to use only one form for that but I have no idea how to do it.

Do you have any idea how to make form/workflow to achieve this goal?

Sorry I'm beginner , I tried to find relevant info but no luck.

Thanks in advance


13 replies

Userlevel 6
Badge +15

HI Marek Lopacinski‌ ! 

I understand your problem, what you want to do makes sense - but my question is, if the form is checking against First Name / Last Name -- what happens if there are several people with that combination? For example, something common like John Smith or Steve Jones or ...Rhia Wieclawek. If it wasn't that exact person, you'd need another piece of data to check against, to make sure and not populate with the wrong info.

It sounds like - if your manager is the one checking on their own - you just need a checkbox to say "Is this a new user?" y/n, and then a rule that says if Y - don't populate the boxes, and if N, show a panel where you request the details for the new user.

Marian Hatala‌ probably knows a better way of doing this, he usually does happy.png  I'm a big fan.

Userlevel 3
Badge +8

There is a workflow way of doing it - check out may's top tip post by Paul Crawford.

For existing users you could use a people picker, if the name is resolved, you would then populate calculated value fields based on the userlookup  function.

If the name doesn't resolve, lets assume it's a new user.. Then the data would need to be collected in 'text fields' or drop downs choice controls etc.

You could have a check box for new user yes/no. This way you could toggle between existing user/new user. Put existing user fields in one panel and new user fields within another panel, that way you can user a rule to hide non need fields in one go.

Userlevel 5
Badge +14

it  is possible within forms as well but it needs a bit of scripting.

as a starting point you need to write your own handler for NF.PeoplePickerApi.added event.  the event is fired once valid user is enetered into PP field.

within the custom handler get entered user's properties and populate them into respective input controls.

see description for people picker API

People Picker Extensions - Nintex Forms 

Badge +2

Hi all,

Thanks for you answers

I created 2 panels  , one with calculated values with data collected from UserProfile Lookup and second with single line boxes for input data manually. All controls are connected to relevant columns in the list. In this solution only data from line textboxes are saved so if I find user via picker these fields are empty so no data is saved. My idea is to disconnect calculated value fields and copy them to the textboxes connected to the list if user exists if not simply I will fill out them manually. Do you know how to do it? ANy other idea? Maybe script mentioned by Marian but I have no idea how to use it

Userlevel 3
Badge +8

I generally do the following:

If you have the 'same' field data for an existing user and a new user i.e. Office . Create a form variable. This form variable field you connect to your SharePoint list column i.e only one column need for either Office value.

In this variable field you have formula i.e. If(equals(MyFormChangeOffice,false),MyFormOffice,OfficeAlternate)

MyFormChageOffice, MyFormOffic,OfficeAlternate are my control names (Settings).

MyFormChageOffice, false - this is your existing user check box value

MyFormOffice is the control of the people picker value.

OfficeAlternate is the manual text control.

Andrew

Badge +2

Good idea Andrew it works for me but I have one problem. I have also person or group column type but there is no form variable which is able to connect to such type.

I have figured out how to copy data from calculated value to textbox field which is connected to relevant list column. I use button for copy and the following code:

NWF$('#'+ varFNm).val(NWF$('#'+ varFN).val()

It is pretty easy but finally I don't want to use button but copy data automatically when for example people picker control is not empty (has proper user value) or when I'm saving form and then depends on check box value  ( if checkbox is

'No" then copy data if "Yes" do not copy) I suppose that I should use IF but I have no idea where and how?

Userlevel 5
Badge +14

this approach will save calculated value to list item.

however, it doesn't work in a opposite way, so once you open existing item in VIEW or EDIT form you will not get populated value from list item field into form control

Userlevel 3
Badge +8

Fair point, I generally only have to do it on new forms to set data. If I wanted updates, then you'd have to set the on form control to the sharepoint column value.

Userlevel 3
Badge +8

Do you need that column type or can you change it for a single line of text column type?  The people column type is great, until (certainly in my environment) I have to do reporting via Excel etc. Then that column type always appends the 'pretty' claims prefix, which is just irritating.

Badge +2

To be honest I thought it will be easier to use this type when I call back to this field to get relevant properties of the user. But as I noticed in the UserProfileLookup function I can use "domainlogin" parameter so there no need to have this type in the list. So I will take it into consideration. Maybe finally I will use this solution.

But I'm still trying to figure out how to use IF using my initial idea (to extend my knowledge)

I need something like this:

IF checkbox=No

 { copy from calculated value fields to textboxes }

or another

IF PeoplePicker has proper value (user exists)

 { copy from calculated value fields to textboxes }

Badge +2

I'd like to use the same approach like Andrew

Userlevel 5
Badge +14

as I've noted above this has to be done with javascript. try to search the forum, there are plenty of examples.

see one of them eg here  

Badge +2

Hi all,

Thanks for inspiration.

Finally I used JavaScript and here is my simple code :

if (NWF$('#' + ddlSwitch1).prop('checked') === false){
NWF$('#'+ varFNm).val(NWF$('#'+ varFN).val());
NWF$('#'+ varLNm).val(NWF$('#'+ varLN).val());
}

Reply