Solved

Nintex Forms for Office 365 Set Text field and dropdown fields based on lookup choice field


Hi

 

I am attempting to set an email address text field and drop-down field base on a user choice field from the same lookup list

 

2652i1D80DCCFB0444E07.png

 

Scenario:

 

there is a list called Travellers which contains Traveller Name, Emal Address, Payment Location  ETC. I need to be able to choose a traveller name from the drop-down and populate the email address field which must remain editable and set the Payment Location drop-down which shoudl also remain changeable.

 

This is not possible using rules and I believe that JavaScript would help however although  I am familiar with JavaScript I wouldn't class myself as able to write anything even close to accomplishing this requirement. I need some pointers and assistance with JavaScript if help can be provided please?

 

Thanka

Chet

 

icon

Best answer by vadim_tabakman 20 June 2019, 16:36

View original

13 replies

Badge +17

Instead of using a list for the email, why not use the user profile and populate the email address for the user directly. It could still be editable, but that would be a text field that is set based on that for you. 


 


I would suggest setting up a calculated control and using the property in the formula for that. This is a super easy thing to implement and makes this request easy to achieve. 


 


Here is the video for that



 


 

I looked into this however there is a list of users who are authorised to travel and come are consultants who are not in AD in the on premises solution. This is why we currently use a list instead of a people picker which I agree would be way simpler

Badge +17

If they are using SharePoint and Nintex forms then they would have some account in user profile to access and fill out the form. So if they have an account in SharePoint, this should work for them also. The list option is not the best approach for this as you are limited in many ways for interacting with the user as a whole. Task and other things like emails become limited.

Thanks Eric, I'll work with the customer to change the list, however there are location and budget codes assigned to each traveller which I'll need to overcome.
Badge +17

Based on your statement for the form, you were wanting them to pull in the username and email address. Location I would think would be determined in the user profile as well. If you want to keep a list for this, its not bad, just not necessary. Also the user entering the form shouldn't be able to change this information for submission, but perhaps verify that the information is correct. This preserves the data.


 


You can use the query list action in the workflow to get the correct codes and locations based on the user name and or email from the list, but this is post submission and not done during form entry. Just a perspective to consider.

I agree with what you're saying there Eric, Unfortunately the payment locatino is a list of offices that wuld be responsible for paying the travel claim and needs to be changeable eg if an employee is on secondment from Washington to London their default Payment Location would be Washington butthey would need to have the ability to change this.

Userlevel 7
Badge +11

Hi Chet,


 


The only way that I can think of doing this, is with some Javascript.  But there's a little more to it.


Assuming you select the Traveler name from a drop down, I would then also add 2 Calculated Value controls.  One that runs a Lookup runtime function to get the Email address from the Travelers list and another Calculated Value  control that does a runtime lookup to the Payment Location.


 


Once you have those, double click on each one, to open the properties, expand "Advanced" and store the Javascript ID variable for each Calculated Value control, in their own variable names.  eg. varCalcEmailAddress and varCalcPaymentLocation


 


Do a "Preview" of this form, and now when you select the Traveler Name from the dropdown, the 2 calculated value controls should auto populate with the corresponding Email Address and Payment Location.


 


Now that you have done this, select both of the Calculated Value controls (Ctrl and click each one) and then add a Rule.  The rule is a "Formatting" rule and the condition is 1==1 and check the "Hide" box.  This is simply to hide these controls from the user.


 


Next, you need to open your actual Email Address text control and Payment Location drop down controls, expand the Advanced section and store the Javascript ID variables for the also.  eg. varEmailAddressID and varPaymentLocationID.


 


Finally, we need to add some Javascript that will connect all this up.  Here's what it's going to do.


 


It's going to find the Calculated Value email address control when the form loads, and add an onchange event handler to it.  When something changes in that control, it run some Javascript, that will take the value, find the "real" Email Address control, and set it's value.


 


We will do the same with the Payment Location control.


 


Javascript:


NWF$(document).ready(function()
{
var calcEmailAddress = NWF$('#' + varCalcEmailAddress);
calcEmailAddress.change(function()
{
var textEmailAddress = NWF$('#' + varEmailAddressID);
textEmailAddress.val(calcEmailAddress.val());
});

var calcPaymentLocation = NWF$('#' + varCalcPaymentLocation);
calcPaymentLocation.change(function()
{
var choicePaymentLocation = NWF$('#' + varPaymentLocationID);
choicePaymentLocation .val(calcPaymentLocation.val());
});
});

I've attached a Form export to this reply (download and unzip it).  It won't 100% work if you import it in, because I'm doing lookups on a list called "Travellers" that exists on my O365 site.  But it might help to have a reference.

Excellent Thanks @vadim_tabakman - I'm working through that as we speak

Hi @vadim_tabakman i followed your instructions to the letter however the fields do not populate, do I need to add anything into the Custom Javascript Includes column?


 


I added 


 


varCalcEmailAddress - to a calculated field which displays the email address
varCalcPaymentLocation to a calculated field which displays the payment location
varEmailAddressID - was added to the Email Address field
varPaymentLocationID - was added to the Payment Location field


and the below script into the Custom JavaScript field - no errors and the form published fine too.


 


NWF$(document).ready(function()
{
  var calcEmailAddress = NWF$('#' + varCalcEmailAddress);
  calcEmailAddress.change(function()
  {
    var textEmailAddress = NWF$('#' + varEmailAddressID);
    textEmailAddress.val(calcEmailAddress.val());
  });

  var calcPaymentLocation = NWF$('#' + varCalcPaymentLocation);
  calcPaymentLocation.change(function()
  {


    var choicePaymentLocation = NWF$('#' + varPaymentLocationID);
    choicePaymentLocation .val(calcPaymentLocation.val());
  });
});

I managed to get your solution working with the fields from my Travellers List now I'll attempt to troubleshoot why my form isn't functioning as expected Thanks

Userlevel 7
Badge +11
That's great to hear 🙂. I hope it's something simple.

Hey @vadim_tabakman,


 


I fixed the issue I had a calculated value that was broken


 


Thanks for your help, now to work on the other issues 


 


Kind Regards


Chet

Hi @vadim_tabakman ,


 


I used your solution inside a repeating section and it worked fine for the first line . But when I tried to add a second line , the values didn't get populated. Any idea how I can modify that to work within  a repeating section.


 


Regards,


KaviRana

Reply