Use this script to warn a user when a specific field on a document is blank. In many workflows, the required attribute of a field may not be practical to implement, but users still need to be aware when the field is left blank. The document in its original state may not have the required data, but at some point in the workflow it should be added, and users should be notified of such a condition.

The following script will inspect an invoice number field on a PO document. If invoice number is left blank, when the document is opened the Live Field will trigger a browser alert window, notifying the user of this condition.

var viewHash = 'viewed-'+$$;
if(!sessionStorage.getItem(viewHash)) {
  sessionStorage.setItem(viewHash, true)
  if($$inject.fields['Invoice Number']=='')
    alert('Warning: Invoice Number is blank on this record.  Please verify no invoice has been received.');  
return "Invoice Verification Checked";

When applied to a Live Field and that field is applied to an archive with an Invoice Number that is blank, opening the document throws the following browser alert: