How a field Dictionary Entry set to Readonly works for UI update versus REST API table update?

chaitanyasaraga
ServiceNow Employee

I have a table with a date field(closed_at) and a number field ( state).

The dictionary entry of the closed_at filed is set to "Read Only". And a business rule (before insert/update) is written to set the closed_at filed to current date when the state = 7.

Now when the state is set to 7 from UI ( list view or form view) of a record, the closed_at field is getting set to the current date value, but when the same state value is set to 7 via service-now REST api(table API) the BR is getting called but the value of the closed_at field is not getting set.

Only the read-only field is unchecked from the dictionary of closed_at filed and saved, it is working fine in both the ways(UI and REST API).

Why so and what is the reason for this behaviour? Appreciate if someone can help me understand the internal (technical) logic behind this behaviour.