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

Repeating Conrol + Current user Name + Time

Jump to solution
TitleCommentModifiedModified By
Test1Test1Comment6/6/2016  10:00:12 pmuser1
Test2Test2Comment7/6/2016  10:00:12 pmuser2
Test3Test3Comment9/6/2016   01:00:00 pmuser3
Test4Test4Comment11/6/2016  11:00:17 pmuser4

Hi ,

I have a nintex form with a repeating control having multiple rows. I want to track which user had done the update i.e. as in above table. I tried using the parameters "CurrentUser" and "Date" but it is modifying all the rows. How can I handle it?

Labels: (3)
Tags (2)
Reply
14 Replies
janeyres
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

Hi,

Could you trap the row added/deleted events in script and handle it that way?

    NWF.FormFiller.Events.RegisterRepeaterRowAdded(function () {      
     });

     NWF.FormFiller.Events.RegisterRepeaterRowDeleted(function () {     
     });

Jan

Reply
pwp08a
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

If that doesn't work try this.  It should change the text field every time either comment or title is changed.

Add a calculated column outside the repeating section set to currentuser.  Store the Client ID in JS variable as currentUser

inside the repeating section add a calculated column with this formula:  user(currentRowNumber() , comment, Title) where comment and Tile are the names of the text boxes in the repeating section.

Add a text box with a css class userName.

Repeating section CSS class: myrepclass

Then paste this in JS




  function user(rowNum, value, valueTitle) {
  repeatingSection = NWF$('.myrepclass');
if (value != "" || valueTitle != ""){
   var currentUse = NWF$('#' + currentUser).val();


   NWF$(".myrepclass .nf-repeater-row").each(function(index){
  
    var $row = NWF$(this);    if( index  == rowNum) {
      $row.find(".userName input").val(currentUse);    }
   
   });
}
}

You can hide calculated column in CSS with display: none;

Reply
Not applicable

Re: Repeating Conrol + Current user Name + Time

Jump to solution

Let us know how the advice is working out for you, aditya gandhe​, thanks!

0 Kudos
Reply
achilles_aditya
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

I have done the following steps:

  1. Added a calculated column outside the repeating section ad in formula I mentioned currentuser.  Store the Client ID in JS variable as currentUser  and I am getting the value of logged in user.
  2. Inside the repeating section add a calculated column with this formula:  user(currentRowNumber() , comment, Title) where "comment" and  "Title" as named controls .
  3. Add a text box with a css class username inside the repeating control/ also tried by adding that inside the repeating control also tried by giving username as  css class as well as css control class
  4. Repeating section CSS class: myrepclass.

Following are the issues:

  • Calculated value in the repeating control is showing #Value.
  • The textbox is showing the value of the "Current User"  for  all the rows and the value gets updated after the execution of javascript.Whereas in a particular row I want to show user who has modified the row last time. i.e it should not update  the values for  all the rows of  "Modified by" column in my example.
  • The statement  $row.find(".userName input").val(currentUse);    is executing for all the rows
Reply
pwp08a
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

1.  Once you get it fixed and working add a css class to the calculated column like hideMe.  then add this in the CSS

.hideMe {

display: none;

}

2.  add an alert in different places to see what is happening when you change the value.

After if( index  == rowNum) {  add this

alert(index);

alert(rowNum);  see what is happening.  it should only alert you when the rowNum from your function and index from for each are equal.

Did you make sure the css class is userName?

Paste from your form the JS bake to here to make sure it copied correctly.

Reply
achilles_aditya
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

Hi,

I have added the alerts and the script seems to be executing as " userName" textbox is showing the value of currentuser.

Since         $row.find(".userName input").val(currentUse) takes the value from the calculated "currentuser field it changes dynamically depending upon the currentuser and the textboxes in all the rows shows the value of currentuser.I am getting the correct value of rownum but the values of currentuser gets updated

Reply
pwp08a
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

This should only change the row that you modified a field in.  If you put the alerts after the If statement, you should only get 2 alerts and it should be the current row number.

You are only wanting to update one row correct?

Reply
achilles_aditya
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

The script is also getting executed on the page load due to which it is overwriting all the values. How can I avoid the script execution on page load?

0 Kudos
Reply
pwp08a
Nintex Newbie

Re: Repeating Conrol + Current user Name + Time

Jump to solution

Ah, forgive me, I cheated on my testing,  I see the problem now.  add two more single line text boxes in your repeating row with these properties

CSS class:  comment hideMe  ........ JS variable:  commentTwo

CSS class:  title hideMe    ................JS Variable:  titleTwo

Then replace your JS with this.  This will compare the title and comment to previous values.  If the same nothing happens...if different it will update the hidden text box and the username.

var valueT = NWF$('#' + commentTwo).val();

var valueTitleT = NWF$('#' +titleTwo).val();

  function user(rowNum, value, valueTitle) {

  repeatingSection = NWF$('.myrepclass');

if (value != valueT || valueTitle != valueTitleT){

alert("this ran");

   var currentUse = NWF$('#' + currentUser).val();

   NWF$(".myrepclass .nf-repeater-row").each(function(index){

  

    var $row = NWF$(this);    if( index  == rowNum) {

      $row.find(".userName input").val(currentUse);

      $row.find(".comment input").val(value);

$row.find(".title input").val(valueTitle);

     }

   

   });

}

}

0 Kudos
Reply