cancel
Showing results for 
Search instead for 
Did you mean: 
ChetChudasamaTS
Nintex Newbie

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

Jump to solution

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

 

Forms_Traveller and Email.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

 

Labels: (1)
0 Kudos
Reply
12 Replies
Community Manager Community Manager
Community Manager

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

Jump to solution

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

 

 

0 Kudos
Reply
ChetChudasamaTS
Nintex Newbie

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

Jump to solution

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

0 Kudos
Reply
Community Manager Community Manager
Community Manager

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

Jump to solution

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.

0 Kudos
Reply
ChetChudasamaTS
Nintex Newbie

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

Jump to solution
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.
0 Kudos
Reply
Community Manager Community Manager
Community Manager

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

Jump to solution

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.

0 Kudos
Reply
ChetChudasamaTS
Nintex Newbie

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

Jump to solution

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.

0 Kudos
Reply
Nintex Employee
Nintex Employee

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

Jump to solution

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.

View solution in original post

Reply
ChetChudasamaTS
Nintex Newbie

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

Jump to solution

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

0 Kudos
Reply
ChetChudasamaTS
Nintex Newbie

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

Jump to solution

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());
  });
});

0 Kudos
Reply