Call Forwarding Help


Not sure if this is the correct forum, if not, please move

I have the below script that I use for immediate call forwarding. I also use A2billing with CallerID authentication for outgoing calls. A issue has just arisen where someone has forwarded their phone to an outside number. The call fails at the A2billing stage due to a CallerID that is not in the table. I have worked round this by adding a route that looks for numbers starting with 77 to bypass A2billing.

My question is - Is it possible to modify the below code so if someone enters an external number (beginning with 9) that it automatically adds 77 to the beginning.

eg - if they enter 90536849564 the system saves it as 7790536849564

exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(call-fwd-unconditional)
exten => s,n(startread),Playback(ent-target-attendant)
exten => s,n,Read(toext,then-press-hash,)
exten => s,n,GotoIf($[“foo${toext}”=“foo”]?startread)
exten => s,n,Wait(1)
exten => s,n,Set(DB(CF/${AMPUSER})=${toext})
exten => s,n,Playback(call-fwd-unconditional)
exten => s,n,Playback(is-set-to)
exten => s,n,SayDigits(${toext})
exten => s,n,Macro(hangupcall,)


Right where your Wait(1) is, just use a basic Set(IF()) to check if ${toext} starts with a 9 and add a 77 if so.