code: def value_from_field_name(field_name, analysis_layer):
      
      field_index = analysis_layer.fields().lookupField(field_name)
      if field_index < 0:
          return None
      else:
          feat = QgsFeature()
          analysis_layer.getFeatures().nextFeature(feat)
          return feat[field_index]
docs: Get the value of analysis layer based on field name.
  
      Can also be used for any layer with one feature.
  
      :param field_name: Field name of analysis layer that we want to get.
      :type field_name: str
  
      :param analysis_layer: Analysis layer.
      :type analysis_layer: qgis.core.QgsVectorLayer
  
      :return: return the value of a given field name of the analysis.
  
      .. versionadded:: 4.0