Hi Garima,
You can achieve this by using a microflow in the selectable object tab of the reference selector tab,
You can visit the question below, there, I’ve explained a use case, that is similar to yours,
https://forum.mendix.com/link/questions/119063
Let me know if you face any issues,
Hope it helps!!
Set the association when you need (and perhaps refresh your context). Basically that is what happens in your autocomplete dropdown; it is a reference (set) selector.