There is a simple way, You need to use filter hook wp_insert_post_data
So the code should be like
add_filter( ‘wp_insert_post_data’, ‘set_post_title_with_field_value’ );
function set_post_title_with_field_value( $data )
{
if ($data['post_type'] == 'sentence' ){
$sentence_number = get_field('sentencia_no', $data['ID']);
$data['post_title'] = $sentence_number;
}
return $data;
}
You need to add this code into theme’s functions.php.
So try the code and let me know the result.
Thanks