How can I write into a Flag's custom field programmatically?
I fix it with this code.
You should save the output of the function

$flag_service-&gt;flag($flag, $entity);   //Wrong method


in a variable like it

$id_flagged_entity = $flag_service-&gt;getFlagging($flag, $entity);


and set the title at this entity

$id_flagged_entity-&gt;set("field_my_custom_field", $link_name);
$id_flagged_entity-&gt;save();