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

Append value from a calculated value to a People or Group field

Hello

 

Can you please advise how to achieve the following:

To copy the value from a calculated value over to a PoG field when a dropdown has changed?

 

I am using the following code:

 

NWF.FormFiller.Events.RegisterAfterReady(function () {
 var departmentField = NWF$("#" +varDepartment);  
 var responsiblePerson = NWF$("#" +varResponsible); 
 departmentField.change(function(){ 
  NWF$("#" + varResponsiblePoG).val(responsiblePerson); 
  });
 });

Department dropdown field = varDepartment

Calculated Value (lookup function to fetch the responsible person based on the department) = varResonsible

The People or Group field = varResponsiblePoG

 

 

Labels: (1)
0 Kudos
Reply
3 Replies
Highlighted
Nintex Newbie

Re: Append value from a calculated value to a People or Group field

Observation: responsiblePerson is a control object (so not its value!!) which you try to insert as a value in varResponsiblePoG.... Would this work at all? Have you tried:

                  NWF$("#" + varResponsiblePoG).val(responsiblePerson.val());

Also, to set a PoG column have a look at https://community.nintex.com/t5/Nintex-for-SharePoint/People-Picker-Extensions-Nintex-Forms/td-p/837...

From that link I currently use these JS snippets for setting PoG fields:

var myappRequestor = new NF.PeoplePickerApi('#' + my_id);
// Search for jon doe and add the first result to the people picker
// Instead you also could use the PreferredName for the user
myappRequestor.search('i:0#w|domain\\jon.doe').done(function (data) {
    myappRequestor.add(data[0]);
});
// Remove a user
myappRequestor.remove('i:0#w|domain\\jon.doe');
// Clears the people picker
myappRequestor.clear()

Hopefully this helps.

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Append value from a calculated value to a People or Group field

@jpmhuls 

 

I tried your suggestion as following but the PoG filed is not updated.

 
NWF.FormFiller.Events.RegisterAfterReady(function () {
 var departmentField = NWF$("#" +varDepartment);  
 var responsiblePerson = NWF$("#" +varResponsible); 
 departmentField.change(function(){ 
 NWF$("#" + varResponsiblePoG).val(responsiblePerson.val());
  });
 });
 

I am not sure how to implement the other JS snippets with the one I am using.

 

 

By the way, whatever value is in +varResponsible should be replicated over to PoG when the dropdown changes.

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Append value from a calculated value to a People or Group field

Whenever I update a field from JavaScript I tend to append .focusout().

NWF$("#" + varResponsiblePoG).val(responsiblePerson.val());

Also if the field is hidden/disabled using the fields Appearance setting, it may not allow to be updated from JavaScript. For this I use a formatting rule, at least as long as there is no validation enforced which you tried to avoid by setting e.g. the Appearance Visible to No.

 

As for the Remove and Clear snippits, this were only for your information in case you need them in another project.

 

As for your last comment, the dropdown change (of Department) is covered by departmentField.change(function(){ }); method.

NB: in case I switched the person fields, please try swapping responisblePerson and varResponsible.

0 Kudos
Reply