Not applicable

setting fields value using jquery

Hi Friends,

 

Using some jQuery code in the Form Settings, I'm trying to set a field's value. For some reason, I'm unable to assign the value

 

Step 1: Created a text column test and used the Client ID javascript variable name as PMValue

Step 2: In form settings, I used this code to extract the string value and assign it to list column

 

NWF$(document).ready(function() {

 

var string = 'Follow Up=10;Meeting=90;Research=20;Transferred=83;';

var auxArray = string.split(';');

var keyValues = [];

 

$.each(auxArray, function(idx, elemString){

   var elem = elemString.split('=');

   keyValues.push({elem});

});

 

NWF$('#'+PMValue).val(keyValues['Follow Up']);

});

 

Can someone please look into this and let me know the modifications I need to make in this code? Thank you

Reply
5 Replies
pfudala
Nintex Newbie

Re: setting fields value using jquery

JavaScript events in Nintex Forms

Could you try to place your code into NWF.FormFiller.Events.RegisterAfterReady instead of NWF$(document).ready() ?

0 Kudos
Reply
janeyres
Nintex Newbie

Re: setting fields value using jquery

Hi,

This should work.

function getIndex(val, vArray) {
    for (var i = 0; i < vArray.length; i++) {      
        if (vArray[0] == val) {
            return i;
        }
    }
}


NWF.FormFiller.Events.RegisterAfterReady(function () {

    var string = 'Follow Up=10;Meeting=90;Research=20;Transferred=83;';
    var auxArray = string.split(';');
    var keyValues = [];
    NWF$.each(auxArray, function (idx, elemString) {
        var elem = elemString.split('=');
        keyValues.push(elem);      
    });
    var arrayIdx = getIndex("Follow Up", keyValues);   
    NWF$('#' + PMValue).val(keyValues[arrayIdx][1]);

});

Jan

0 Kudos
Reply
Not applicable

Re: setting fields value using jquery

Hi Jan,

Thank you for suggesting the modifications and it does work as expected. However, I noticed that the even though I change the 10 to 20 for the Follow Up, the value in the PMValue remains the same.

Can you please suggest any ideas?

0 Kudos
Reply
janeyres
Nintex Newbie

Re: setting fields value using jquery

Hi,

Where are you changing the 'Follow Up=10;Meeting=90;Research=20;Transferred=83;' value? Is it in another field on the form?

The NWF.FormFiller.Events.RegisterAfterReady event only runs once when the form loads so if the value is changed after that the PMValue field won't show the new value;

Thanks

Jan

0 Kudos
Reply
Not applicable

Re: setting fields value using jquery

Hi All,

 

I used this code to get the info I needed

var str = NWF$('#'+ TValue).val();

var strArr = str.split(';');

var index = 0;for(var i = 0; i < strArr.length; i++){

    if(strArr.match("Follow Up")){

        index = i;

    }

}var temp = strArr[index].split('=')[1];

 

NWF$('#'+PMValue).val(temp);

 

For some reason, the val() was not getting the data. So I wrote this on the Submit button and it worked.

 

Thank you everyone for your help

0 Kudos
Reply