Count people in people picker field
Posted by coresoul - Jun 10 ’15 at 09:46
i have a deue date field in the form which will calculate the due date based on no of approver (peopl picker field) times no of days they have to approve task plus today's date. i have a people picker (multiple value enabled) field and would like to calculate the no of people.
eg. no of people in people picker =3
no of days each approver gets (number field)=2 days
today's date=6/10/2015
Due Date=6/10/2015+3*2
i have a people picker (multiple value enabled) field and would like to calculate the no of people.
how can i achieve this? Please help
i have a deue date field in the form which will calculate the due date based on no of approver (peopl picker field) times no of days they have to approve task plus today's date. i have a people picker (multiple value enabled) field and would like to calculate the no of people.
eg. no of people in people picker =3
no of days each approver gets (number field)=2 days
today's date=6/10/2015
Due Date=6/10/2015+3*2
i have a people picker (multiple value enabled) field and would like to calculate the no of people.
how can i achieve this? Please help
Hello,
Please use the following code:
Please ask if you have any questions.
Please use the following code:
Code: Select all
var peopleCount = 0;
//if the people picker is client side rendered
if (fd.field('People').value().constructor == Array)
{
peopleCount = fd.field('People').value().length;
}
//else it is rendered server side
else
{
peopleCount = fd.field('People').value().dictionaryEntries.length;
}
var numberOfDaysForApprover = fd.field('NumberOfDaysEachApproverGets').value();
var date = new Date(fd.field('TodaysDate').value());
// if the today's date field is not empty
// this code assumes US date format is being used
if (Boolean(fd.field('TodaysDate').value())) {
var dateParts = fd.field('TodaysDate').value().split('/');
var date = new Date(dateParts[2], dateParts[0]-1, dateParts[1]);
date.setDate(date.getDate() + peopleCount*numberOfDaysForApprover);
var dueDateString = (date.getMonth()+1) +"/"+date.getDate() +"/" + date.getFullYear();
fd.field('DueDate').value(dueDateString);
}
Please ask if you have any questions.
-
- Information
-
Who is online
Users browsing this forum: No registered users and 21 guests