Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS3 call a function from different DataObject

Go to End

5 Posts   1238 Views


Community Member, 52 Posts

1 February 2013 at 10:16pm

Hi All

This may be simple but im just not sure

I have a dataobject extension that has a function with a query in it, i want to access that function from a different dataobject extension.
Can this be done? and how?



Community Member, 187 Posts

2 February 2013 at 12:25am

Create it as a static function:

Class MyDataObject extends DataObject {

    public static function foo() {
        // Do some querying


You can then call it by doing:



Community Member, 52 Posts

2 February 2013 at 9:33pm

Hi Kinglozzer

Thanks for your reply, when i made the function public static the wheels came off a bit and nothing worked.

although this gives me something to go on unfortunatly i have little time to explore this right now so i will plug away as i get time and try a few things and see what i get working

thanks again



Forum Moderator, 5523 Posts

4 February 2013 at 8:05pm

If it's static you need to refer to the extension classname (e.g MyDataExtension::foo()). If your method is instance based you need to go $this->owner->foo().


Community Member, 52 Posts

5 February 2013 at 10:35pm

Thanks Willr

I managed to work that bit out as in MyDataExtension::foo() and kind of got it working but not well, in the page view it returns a value for each object but dosn't seem to be running the query.

at this point i think i need to play around a little with this to get the result i am looking for.