<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def edit_record(self, new_record):
 """ Update a record in ArchivesSpace using the provided new_record. The format of new_record is identical to the format returned by get_resource_component_and_children and related methods; consult the documentation for that method in ArchivistsToolkitClient to see the format. This means it's possible, for example, to request a record, modify the returned dict, and pass that dict to this method to update the server. Currently supported fields are: * title * targetfield * notes * start_date * end_date * date_expression :raises ValueError: if the 'id' field isn't specified, or no fields to edit were specified. """

        try:
            record_id = new_record["id"]
        except KeyError:
            raise ValueError("No record ID provided!")

        record = self.get_record(record_id)

        # TODO: add more fields?
        field_map = {"title": "title", "level": "levelOfDescription"}
        fields_updated = False
        for field, targetfield in field_map.items():
            try:
                record[targetfield] = new_record[field]
                fields_updated = True
            except KeyError:
                continue

        if self._process_notes(record, new_record):
            fields_updated = True

        # Create dates object if any of the date fields is populated
        if (
            "start_date" in new_record
            or "end_date" in new_record
            or "date_expression" in new_record
        ):
            date = {
                "jsonmodel_type": "date",
                "date_type": "inclusive",
                "label": "creation",
            }
            if "date_expression" in new_record:
                date["expression"] = new_record["date_expression"]
            if "start_date" in new_record:
                date["begin"] = new_record["start_date"]
            if "end_date" in new_record:
                date["end"] = new_record["end_date"]

            if len(record["dates"]) == 0:
                record["dates"] = [date]
            else:
                record["dates"][0] = date

            fields_updated = True

        if not fields_updated:
            raise ValueError("No fields to update specified!")

        self._post(record_id, data=json.dumps(record))