current.isNewRecord() gives false when used in calculation field

ryadavalli
Tera Expert

current.isNewRecord() gives false when used in calculated value on a field on a change record for create newswhen used in calculation field on a change record for create new

18 REPLIES 18

That's true. so current.isNewRecord() should return true when I create a new record, right ? or you meant to say that current wonnot work at all?


Current won't work in the calculated field because the field isn't created until after it is created (chicken and egg scenario.)



In a script, it makes perfect sense to say:



if (current.isNewRecord())


        // user is looking at a new form - nothing saved yet


else


        // user is looking at the values from an existing record


Hmm.. it is not going into IF when I create new using the below, what I am missing? I want field to be false if new record, else have true value.



if(current.isNewRecord()){


gs.addInfoMessage("IF");


current.u_assessment = false;


}


else{


  current.u_assessment = true;


}


I have tried that too. For some reason it returns false all the time when I place a log. But, I cannot give you any explanation


What about setting the default in the dictionary to true, then use an onLoad client script like this:



function onLoad() {


        if (g_form.isNewRecord())


                  g_form.setValue('assessment', false); // turn off the checkbox for brand new records only


}