Calling a function via button from instance of prefab

Hello! I will try to put this as simple as possible.
I am creating an instance of a prefab which has buttons on it. If i use the “onClick()” function in the inspector the instnace wont have the script saved. (button unassigned).
My best bet was to acces the isntance, get the child as an Object and then using GetComponent getting the Button. Then i am using the method that the unity scripting api suggests ( My problem is that: somehow the function that is supposed to be called by the button is not.
Here my code:
openAdvBtnGo = dayDisplayInstance.transform.GetChild(5).gameObject; //Go = GameObject ==> openAdvBtnGo = GameObject openAdvBtn = openAdvBtnGo.GetComponent.(); var openAdvBtnScript : Button = openAdvBtn.GetComponent.(); openAdvBtnScript.onClick.AddListener(OpenAdvPnl);
I dont get any errors, it just doesnt execute the code in the “OpenAdvPnl” function.
I even tried putting a simple print("is this function even executed?") in the beginning of the function but it wont work. I am seriously stuck here. Any help would be much appreciated!

Used a second script attacked that to the prefab and then i just assigned variables in the inspector. This worked! (was a tip from a friend)