Fetch assigned to value in a custom field

Hi All,
How can I fetch the documents assigned to name to a custom field.
So far I have tried below code:
cur_frm.doc.assigned = cur_frm.get_docinfo().assignments[0].owner

This returns the assigned owner name only for the documents which have the value, for null value the screen freezes.

The requirement is to fetch the assigned value in a custom field as soon as the document is added in To Do.

Please Help.