dialparties.agi originates from FreePBX, and a lot of the logic for things would originate from there too. You may have better luck on the FreePBX forum instead of here.
In addition, ANI is not the same as CLI and is not something that, say, SIP provides (although nowhere do you say you are using SIP). ANI is not what you normally want for call back.
I’m connecting the callback call to another field. And the cli here is important to me, The use of mandatory cli is not working here. I need to show the real caller number for the project.
Unless you are another network operator, someone like the police, or, in some countries, the number called is a free number, networks operators generally won’t give you Accounting Number Information. Even when they do, there may be cases when it is not the primary number of the line used to make the call.
To have a chance of receiving ANI, you are likely to have to have an ISDN connection, but I’m not sure whether Asterisk actually captures that information and populates CALLID(ani).
For Calling Line Identification, the default behaviour of Asterisk sis to pass that through as received, although note that the default, for SIP, is to assume it is contained in user part of the the From: header. If it is contained elsewhere, you may have to enable trustrpid, or even explicitly parse it from a header.
There are no macros provided with Asterisk and their use is deprecated. FreePBX has many macros, but is not supported on this forum.
I’m having trouble working out what you are actually doing, even to the extent of being able to work out what is being provided by FreePBX and what by Asterisk. Also, you haven’t yet told us the signalling protocol being used.
You need to start by seeing how the information is communicated in the actual SIP protocol exchanges. If it is not there, you have to stop at that point.