code: def touidref(src, dst, src_relation, src_portal_type, fieldname):
      
      field = dst.getField(fieldname)
      refs = src.getRefs(relationship=src_relation)
  
      if len(refs) == 1:
          value = get_uid(refs[0])
      elif len(refs) > 1:
          value = filter(lambda x: x, [get_uid(ref) for ref in refs])
      else:
          value = field.get(src)
      if not value:
          value = ''
      if not field:
          raise RuntimeError('Cannot find field %s/%s' % (fieldname, src))
      if field.required and not value:
          logger.exception('Required %s field %s/%s has no value' %
                           (src.portal_type, src, fieldname))
      field.set(src, value)
docs: Convert an archetypes reference in src/src_relation to a UIDReference
      in dst/fieldname.