Asterisk Dial pLan with (g) option

Hello I am attempting to log a call on completion the dial-plan is massive and has contingencies
If (callagent) is not answered it continues down the dial-plan however if the call is answered I need to upon completion of that call jump to (logresult).

As I understand it I can use Dial option (g) to come back to dial-plan. I need to set a variable letting me know that the call was connected So I can add logic and I am not sure how to determine if that call was answered in the dial plan.

Any Help Appreciated.
Asterisk 1.8

exten => 1234,1(agent),PlayBack(shortly)
exten => 1234,n,Ringing
exten => 1234,n(callagent),Dial(SIP/backup2/${qryresult},12,g,)
exten => 1234,n,PlayBack(busyagents)
exten… Lots more
exten => 1234,n(Logresult),SET(qryresult1=${ODBC_MSSQLProc(${CALLERID(num)},${CHANNEL})})
exten => 1234,n,Hangup()

g will only continue if there is still an incoming channel. If you want to do something when there is no channel, you need to use the h extension.

By the way, this is not a support forum.