Populate fields based on Current User


Userlevel 4
Badge +10

Hi Folks,

I have an issue that should be obvious but I do not see this issue handled in another post.

I am useing Nintex Fomrs 2016 (on-prem) and the form is classic.

My form should auto-populate based on {Common:CurrentUser}.

Fields to populate (based on a list in another site within the site collection) are...

  • Last Name
  • First Name
  • Employee ID
  • User ID
  • Email
  • Phone
  • Area/Section

 

If the form needs to be submitted on behalf of another user, then the current user will select that other employee from a list lookup control that already seems to be working correctly.

Once the form is submitted, we want to lock down the fields so that they cannot change, and of course, they should NOT auto-populate again when the form is opened by another user.

We are getting the curernt user to show up in a calculated control with the following formula:

userProfileLookup(Current User, "PreferredName")

Hopfully someone out there has done this or can point me in the right direction.

 

Thanks and regards,

Patrick Kelligan


15 replies

Badge +4

Can you send the configuration screenshot of one of the field you are prepopulating based on the lookup or current user.

Userlevel 4
Badge +10

Hi @rameshmusham,

 

Sure. Below is the configuration of the last name control that I am trying to auto-populate. All of the other controls are configured similarly.

 

2464iDBF635BAB3A4148E.png

Badge +4

I don't know why you are using Javascript instead of built in Runtime Funtion to get the lookup values from other list "lookup()" in calculated column. 

 

You can add a rule (Formatting) on the fields that should be locked (disabled) other than new form and write a condition as not(Is New Mode) and select Disable.

 

You can also update the calculated field userProfileLookup(Current User, "PreferredName") to Recalculate only on new mode need to be YES , Edit mode-No, View Mode-No and this applies to all the auto populated columns (if you use runtime function lookup()).

Userlevel 4
Badge +10

Thanks for the reply @rameshmusham,


@rameshmusham wrote:

I don't know why you are using Javascript instead of built in Runtime Funtion to get the lookup values from other list "lookup()" in calculated column. 


Because do not know how to do what you are suggesting. If I use the following...

lookup("/ASP/PMO/AdminWebDB|tbl_Westerners","ID",????,"LastName")

...what do I put in the "value to filter on" argument (assuming I am using the other arguments correctly)? I suspect it should be something from the current user calculated field output but I am not sure how to configure it.

 


@rameshmusham wrote:

You can add a rule (Formatting) on the fields that should be locked (disabled) other than new form and write a condition as not(Is New Mode) and select Disable.


Yes, I understand how to lock down the controls with formatting rules. My concern was more with keeping the controls from auto-populating again after the from has been submitted again. It looks like you adressed that in the final sentence of your reply. I will look that over and see if I can make it work.

 

Thanks and Regards,

Patrick

Badge +4

You mentioned in the subject based on current user, so i thought you are using the current user to filter on the list and you have something that similar to current user/dropdown list (other employee) that you are filtering on the other list.

 

Can you tell me based on what value are filtering and which column you are fitlering to prepopulate the values.

Userlevel 4
Badge +10

Hi @rameshmusham,


@rameshmusham wrote:

You mentioned in the subject based on current user, so i thought you are using the current user to filter on the list and you have something that similar to current user/dropdown list (other employee) that you are filtering on the other list.


Yes, that is the rub. I prefaced with "Current User" because for years I have tried to use things like the Web Request control to access LDAP but to no avail. I even sat down with some of the Nintex folks at two different conferences (Las Vegas and San Diego) but we were unable to get it to work. The closest we could come is by accessing the {Common:CurrentUser} feature. I Use current user as part of the List lookup control when requesting "on behalf of" successfully so I natually go there with this other train of thought. If there is a better way to do this other tan current user, I am definatly willing to try other things.


@rameshmusham wrote:

Can you tell me based on what value are filtering and which column you are fitlering to prepopulate the values.


Well, I have not figured it out on the initial auto-populate but here is how we are doing the list lookup part.

The list lookup config is as follows with "jsvar_EmployeeLookup_LLU" as the Client ID JavaScript variable name.

2470i870D2902AE5604FF.png

The calculated value control for the Last Name, by example, is configured as follows with Client ID JavaScript variable name of jsvar_LastName_CAL.

2471i784528BF76D7938A.png

 

Now, the code that runs this process is as follows...

function() {
	if (NWF$('#'+ jsvar_EmpID_CAL).val())
	{
		NWF$('#'+ jsvar_EmpID_TXT).val(NWF$('#'+ jsvar_EmpID_CAL).val());
		NWF$('#'+ jsvar_LastName_TXT).val(NWF$('#'+ jsvar_LastName_CAL).val());
		NWF$('#'+ jsvar_FirstName_TXT).val(NWF$('#'+ jsvar_FirstName_CAL).val());
		NWF$('#'+ jsvar_MI_TXT).val(NWF$('#'+ jsvar_MI_CAL).val());
		NWF$('#'+ jsvar_Section_TXT).val(NWF$('#'+ jsvar_Section_CAL).val());
		NWF$('#'+ jsvar_DateOfHire_DTE).val(NWF$('#'+ jsvar_DateOfHire_CAL).val());
		NWF$('#'+ jsvar_Phone_TXT).val(NWF$('#'+ jsvar_Phone_CAL).val());
		NWF$('#'+ jsvar_EmployeeEmail_TXT).val(NWF$('#'+ jsvar_EmployeeEmail_CAL).val());
		NWF$('#'+ jsvar_Gender_CHO).val(NWF$('#'+ jsvar_Gender_CAL).val());
		NWF$('#'+ jsvar_PassportNumber_TXT).val(NWF$('#'+ jsvar_PassportNumber_CAL).val());
		NWF$('#'+ jsvar_PassportExpiration_DTE).val(NWF$('#'+ jsvar_PassportExpiration_CAL).val());
		NWF$('#'+ jsvar_SupervisorEmail_TXT).val(NWF$('#'+ jsvar_SupervisorEmail_CAL).val());
	}
}

let me know if this answers your questions or if I left anything out.

Thanks and regards,

Patrick

 

 

 

 

 

 

 

 

 

 

Badge +4

Can you please take a look of the attached use case document and let me know are you trying to achieve the same scenario or not.

Userlevel 4
Badge +10

Thanks for the use case @rameshmusham!

I have looked it over and first, the not(Is New Mode) is cool! I did not know how to use that. Thanks!!

The overall princilpe is what I need to accomplish. I have a snag however.

Your list called TestB coresponds to my tbl_Westerners.

The paths for my lists are as follow:

  • ListA: /ASP/dev/T1
  • ListB: /ASP/PMO/AdminWebDB/Lists/tbl_Westerners

In your use case, the fomula you create references ListB assuming it will be colocated in the same site. Is there a way for me to reference this in another site within the same site collection?

 

Also, just to satisfy my curiosity, there is a point in the formula where you use single quotes as opposed to double quotes. Is there a reason for this?

 

Thanks and Regards,

Patrick

Userlevel 4
Badge +10

..also, I just tried the following formula to try and reach the other site and it did not work.

if(cv_CurUserPreferredName && isNullOrEmpty(llu_Western_Employee),lookup("/ASP/PMO/AdminWebDB|tbl_Westerners","LastName","FullName",cv_CurUserPreferredName,'FirstName'),lookup("/ASP/PMO/AdminWebDB|tbl_Westerners","LastName","FullName",parseLookup(llu_Western_Employee),'FirstName'))

Do you see any issues with my syntax or typos I maght be missing?

Badge +4
if(cv_CurUserPreferredName && isNullOrEmpty(llu_Western_Employee),lookup("/ASP/PMO/AdminWebDB|tbl_Westerners","LastName","FullName",cv_CurUserPreferredName,'FirstName'),lookup("/ASP/PMO/AdminWebDB|tbl_Westerners","LastName","FullName",parseLookup(llu_Western_Employee),'FirstName'))

I see that you added LastName in the formula which is not required, as we are filtering based on fullname from the second list - you can use the below formula

if(cv_CurUserPreferredName && isNullOrEmpty(llu_Western_Employee),lookup("/ASP/PMO/AdminWebDB|tbl_Westerners","FullName",cv_CurUserPreferredName,"FirstName"),
lookup("/ASP/PMO/AdminWebDB|tbl_Westerners","FullName",parseLookup(llu_Western_Employee),"FirstName"))

and let me know the results. The single or double quotes doesn't matter.

Userlevel 4
Badge +10

Hi @rameshmusham,

I was not able to get the use case working on my primary test project that I posted from previously. Instead, I strated from scratch to see if I could get your exact use case built on my site wothout referrencing another site. I think I got it to work for the most part. My only problem is that the values do not show uop in the actual text fields until it is submitted and reopened.

2486i99E35106B35A52DA.png

The following is before submission...

2488i2AEA79640160E828.png

 

...and this is after submission

2487i61F7A46B533552DC.png

 

Can you tell me what I am missing?

Badge +4

May i know the reason why you are using the text fields to save the data again from calculated column's?

Userlevel 4
Badge +10

@rameshmusham wrote:

May i know the reason why you are using the text fields to save the data again from calculated column's?


Well this is awkward. Because that is the way I have always done it. :smileywink:
I started creating forms in InfoPath originally and that is how I was taught to do it. Please help me understand why I should not.
I do need to store the data in the list but I suspect if I connect/bind the calculated controls to the list columns that would have the same effect as long as I do not allow the calculated controls to recalculate after submission.


A couple of other questions on this theme... In your use case, the fields looked like text fields with the white background (one of the reasons I thought you were using regular text fields). Is there something you are doing different in your use case that I am not catching on to?
Also, you use the term calculated column. Is that the same as using a calculated control or is it something different?


Thanks for all of you input and assistance!
Patrick

Badge +4

In general i use calculated columns to be connected to list columns to update the list. I tried my best and i have a workaround to update the text box by clicking on it:

jsvarfname is for textbox

jsvarfirstname is for calculated column.

 

NWF$(document).ready(function(){
NWF$("#"+jsvarfname).click(function(){
NWF$("#"+jsvarfname).val(NWF$("#"+jsvarfirstname).val());
});
});

Userlevel 4
Badge +10

Thanks @rameshmusham ! I got your Use Case working in my work probelm! This will change the way I do things moving forward as most of my projects require auto-populate.


@rameshmusham wrote:

...I tried my best and i have a workaround to update the text box by clicking on it:

jsvarfname is for textbox

jsvarfirstname is for calculated column.

 

NWF$(document).ready(function(){
NWF$("#"+jsvarfname).click(function(){
NWF$("#"+jsvarfname).val(NWF$("#"+jsvarfirstname).val());
});
});


I will play with this code and see if I can make it work.

 

Thanks and Regards,

Patrick

Reply