cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Nintex Forms If then statements

Jump to solution

Hello all,

I am brand new to Nintex so I will do my best to explain what I am needing help with. I have a SharePoint control on the page that has 2 check boxes (1/2year, 1year). I need to populate a second controls value based off what the user selects.

If user selects 1/2year add 6 months to todays date and populate the date control.

If user selects 1year add 12 months to todays date and populate the date control.

with my limited knowledge I am guessing I need a IF statement for both checkboxes and a then statement attached to each to populate the date control.

Please excuse me if my terminology is not correct, not a dev of any kind having to self educate on this.

Thanks

Jason

Labels: (1)
0 Kudos
Reply
5 Replies
Highlighted
Workflow Hero

Re: Nintex Forms If then statements

Jump to solution

Hi Jason Goudy,

You need to include some javascript on the form.

First thing is that you may need radio buttons instead of checkbox because check boxes are multi select. Users can select 1/2 yr and 1 yr both options. Is this your intent?

To set the date picker and perform calculations, there is great article from Vadim and others that you will find on the community.

Nintex Forms - Date Calculations with Javascript - Vadim Tabakman

Setting current date and time on control


Hope this helps.

Reply
Not applicable

Re: Nintex Forms If then statements

Jump to solution

Kapil Joshi,

Thanks so much for your feedback, so here is what I did. I changed the control "Choice1" to a drop down. Its options are "1/2 Year" and "1 Year". Then I wrote the following Java script based off the examples I read. My goal is that if the drop down = "1/2 Year" to add 6 months to todays date and populate the Date1 control with it. then once I get that working I will modify it and add code to add 12 months if its a year. Again I have never coded so please don't laugh to hard if this is completely off base.

function setDate() {

  var sel = NWF$('#' + choice1).val();

  if (sel == "1/2 Year") {
    var d = new Date();
d.setFullYear(d.getFullYear(), d.getMonth() + 6);
var mm = d.getMonth()+1;
var dd = d.getDate();
var yyyy = d.getFullYear ();
    var date = mm + '/' + dd +'/' + yyyy;
    NWF$(Date1).val(date);
  }

}

2nd part. Once I get the Java Script correct. I am confused how to add it to my form. I understand that under form settings there is a custom JavaScript section I can copy it into. Then I also read that on the date control store client id. then that will give me a field to put a client id in. I don't understand where the client ID is my code. or how to call it. Thanks again for baring with me as I learn.

0 Kudos
Reply
Workflow Hero

Re: Nintex Forms If then statements

Jump to solution

Hi Jason Goudy

Modify the last line in your code to this:

NWF$('#' + Date1).val(date);

Date1 is the Client ID Javascript Variable name. You define this in the date control.

Open the settings of the date control, expand Advanced section, Select Yes for "Store Client ID in JavaScript variable". In the field "Client ID Javascript Variable name" enter Date1.

See the images below:

example.jpg

This variable will identify the value you select from the drop down and pass it to the Javascript function setDate().

example.jpg

When returning the value from Javascript, Date1 will identify where to set it.

0 Kudos
Reply
Not applicable

Re: Nintex Forms If then statements

Jump to solution

Thanks that helps clarify how to set up Nintex to use my java script. unfortunately it is still not working. Here is how I have everything setup.

Form - Settings

N-Java-form-Settings.png

Choice Control - Settings

N-Java-Choice-Controls.png

Date Control - Settings

N-Java-Date-Controls.png

When I preview the form and use the choice drop down and select "1/2 Year" the date field does not populate.

Am I missing something?

0 Kudos
Reply
Not applicable

Re: Nintex Forms If then statements

Jump to solution

I Got it. to work. I had an error in my javascript. THANK YOU so much for all your great help.

0 Kudos
Reply