cancel
Showing results for 
Search instead for 
Did you mean: 

Setting default values for text, date, people and group fields

alandau
Champ in-the-making
Champ in-the-making
We are looking to set defaults on a few fields and it is not clear how to accomplish this using Kickstart.

Text box – Set a default text
Date – Set to today's date or a date in the future
People – Set to the current logged in user
Group – Set to a default group

In the formRendered JS we have included

var test = "this is a test string";
var currentUser = scope.$root.account;

for (var fieldArrayIndex = 0; fieldArrayIndex < scope.allFormFields.length; fieldArrayIndex++) {
    var field = scope.allFormFields[fieldArrayIndex];
    console.log(field.id + ' ' + field.value + ' ' + field.type);
    if (field.id === 'mytextfield') {
        field.value = test;
    }

    if (field.id === 'mypersonpicker') {
        field.value = currentUser;
    }
}  

The same form is used on both the start node and human task.  In both cases it is blank.  When the task loads you can see the value set from the previous form, but then it is blanked out when it gets to code.


1 REPLY 1

alandau
Champ in-the-making
Champ in-the-making
This is resolved….

var currentUser = scope.$root.account;
console.log(currentUser);
console.log(currentUser.id);



//for(i=1;i<40;i++)
//    {
//    console.log("The value is : " + scope.allFormFields.value+" with index : "+i);
//    }
   
for (var fieldArrayIndex = 0; fieldArrayIndex < scope.allFormFields.length; fieldArrayIndex++) {
    var field = scope.allFormFields[fieldArrayIndex];
    console.log(field.id + ' ' + field.value + ' ' + field.type);
    if (field.id === 'myfield' && !field.value) {
        field.value = "12345";
    }
    if (field.id === 'date' && !field.value) {
        var currentDate = new Date();
        field.value = currentDate.toISOString();
    }
    if (field.id === 'approver' && !field.value) {
        field.value = currentUser;
    }
   
}  

console.log('end');