Serial No Doctype is coming as not saved after save

Hi ,
I wrote Custom script for Serial Number doctype using trigger “refresh.”
I created some custom fields in Serail No with Data Type Long text.I am attaching files to Serial No doctype and fetching the file_url from File list and displaying in custom field after that i am making that custom fields as read only.Once i do refresh after attaching file i am getting the file_url but not able save the Serial No doc type, it is showing as Not saved.Please suggest me how to save that Serial No doctype.
Thanks in advance,

What is your use case?