i would troubleshoot 'bottom-up' and use lowercase for variables (not sure if that has an impact, but it is a good practice).
i don't know what XXX#YYYY is, but it needs to exists as a header, or whatever you use instead of XXX#YYYY. so lets see if it exists first in the logs.
when HTTP_REQUEST {
foreach header_name [HTTP::header names] {
log local0. "$header_name"
}
if { [HTTP::header exists x-id] } {
set value [HTTP::header "XXX#YYYY"]
#log command to determine if VALUE is set correctly
log local0. "x-idlog var value=${value}"
# header x-id allready exists -> remove it first.
HTTP::header remove x-id
# add header x-id with variable value
HTTP::header insert x-id $value
}
}
check system > logs > local traffic for errors and logs.