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

Chuck Tomasi
Tera Patron

Hi Ravali,



Can you share the calculation you are using in that field? I suspect that the calculation isn't done until the field is saved, but would like to hear more details of your use case.


it is field called assessment. it has script something like this. When I create new change, it should get into else as it a new record, but it is   returning false with current.isNewRecord and gets into IF.



if(!current.isNewRecord()){


    current.u_assessment = true;


}


else{


current.u_assessment = false;


}


also


current.sys_id, current.number all are returned empty when I put them in the calculate value of the field


That confirms my suspicion that current doesn't have values until the record is created.



isNewRecord() basically says "The information you are looking at hasn't been saved to the database yet.", not "This is a brand new record saved to the database."



Hopefully that will allow you to use it properly and set the value of your assessment field accordingly (and the logic around it.)