Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Why "current" doesn't work well in "Default value"?

jamesgo
Giga Contributor

If I put "javascript:current.sys_id;" in "Default value" field for an dictionary, it doesn't return anything when trying to create a new record… but if I put "typeof current" it does return "object", and "javascript:current.getTableName();" does work too. Any idea why?

1 ACCEPTED SOLUTION

eican
Kilo Guru

Because the record has no sys_id until it is saved in the DB.


View solution in original post

3 REPLIES 3

eican
Kilo Guru

Because the record has no sys_id until it is saved in the DB.


jamesgo
Giga Contributor

I haven't check, but I guess all the GlideRecord methods work at this time?


The methods work but you are trying to get a value of a field which does not have a value yet.


You can check for that also using 'current.isNewRecord()' => https://wiki.servicenow.com/index.php?title=GlideRecord#isNewRecord