Skip to main content

I came upon this issue, where our client want to have a dropdown for people picker with a list of users in a group. This is for O365 and I do not see a control for this functionality in Nintex Forms.

 

Options I tried:

 

Option 1

I tried to write javascript function to populate the dropdown with user names but on Save or Submit I get the event validation issue (reading up on the forum suggest that this is a known issue), I would have to further save the value in another field, clear the dropdown before Save/submit and also on form load, load the options and set the selected index. This seems like too much work as I have about 5 such fields.

 

Option 2

Have a people field and a multi line textbox. A javascript function will run a RESt API call and populate the text box with the people in the group. The user will use this as a reference and start typing in the people field to choose the approver.

 

Option 2 will not be very desirable for the client, but if that is the new experience, we would have to talk to them about it, but I wanted to be sure before I make that call.

 

Is there any other control/method for this functionality to happen?

 

Thanks for any help/suggestions

I too have come across this scenario (but on On-Premise). I went on to implement the Option#1 that you have mentioned, wherein I came up with a common function which was used for multiple such controls.

  1. On New form
    1. Get list of user by making REST API call and bind it to drop-down as options
    2. On drop-down change, event set the drop-down selected value to a hidden People Picker control which is mapped to List column
  2. On Edit form
    1. Get list of user by making REST API call and bind it to drop-down as options
    2. Get the hidden People Picker value and set it as drop-down selected value

NWF$(document).ready(function () {
if (Is New Mode)
BindApproverNames(NWF$("#" + choApproverName));
if (Is Edit Mode)
{

SetApproverNames(NWF$("#" + choApproverName),NWF$("#" + pplApprover));
}
});

function BindApproverNames(control)
{
control.find('option').remove();
control.append('<option value=""-1"">' + 'Please select a value...' + '</option>');

NWF$.ajax({
type: 'GET',
url: <<url>>,
dataType: 'jsonp',
contentType: 'application/json',
async: true,
success: function (data) {
if (data.esError != 'undefined' && data.esError.type != '' && data.esError.type == 'S')
{
NWF$.each (data.employees, function (key, value) {
approverNames.append('<option value=' + value.employeeId + '>' + value.fullName + '</option>');
});
}
}
});
}

function SetApproverNames(control,pplControl)
{
//get employee ID of the value in the People Picker- You can costomise as per your needs
var approverID = "";
var selectedAccount = pplControl.val();
var slashPos = selectedAccount.lastIndexOf("\");
var selectedLogin = selectedAccount.substring(slashPos + 1,selectedAccount.length-1);
// Getting selected user details from AD via ADLookup Web API
var wsURL = WebApiUrl + 'ADLookup/GetUser?Id=' + selectedLogin; //this is custom
NWF$.ajax({
type: 'GET',
url: wsURL,
dataType: 'jsonp',
contentType: 'application/json',
async: true,
success: function (data) {
approverID = data.employeeId;
}
});
//since employeeId is used as value in the drop-down option
NWF$("#"+ choApproverName).val(approverIDValue) ;
}


Thanks for your reply, I pretty much followed this link and got my issue resolved.

How to Create Cascading Choice Controls – Nintex Forms 


Can your code sample be used to get a list of users from a SharePoint Group? If so, do you replace << url >> with the URL of the SharePoint Group? e.g.:

url: 'http://server/manage/site/_layouts/15/people.aspx?MembershipGroupId=123'

Also, there are a few invalid JavaScript lines (e.g. "Is New Mode") and undefined variables (WebApiUrl). Do you mind at least showing samples of what these should contain, even if you use fictitious names? For example, I have no idea how to define the New or Edit mode condition, nor what my WebApiUrl should be.

Thanks in advance.


Reply