If I well understand, the “Name” comes from a field filled by the user in the same time he changes the value.
I don’t know what is your trigger (a classic save button ? an Ajax request ?), but I presume that you can first use the “acf_update_value” filter to register the new Name, after what you can call your current custom function and bring the Name with get_field('name', $post_id)
. ($post_id is already set as a parameter in your custom function).