Get url in a bean

Is posible get the URL from a specifyc bean?

example in a hook:


public function helloWorld( &$bean, $event, $arguments)
	{
		echo $bean->getTheUrl();
                exit;
	}

I currently do this


echo $sugar_config['site_url']."/index.php?module=module_name&action=DetailView&record=".$bean->id;
exit;

So, does this code work well for you?

What exactly are you asking, if there is a function for this already in the core code? If so, I think the answer is no, not that I know of…

1 Like

Not works, this just is a question if exist something like that

[strike]$bean->getTheUrl();[/strike]

thanks!

I don’t know of any function like that, I assume it does not exist.

I think that code you have in the “echo” statement should work well, at least for most kinds of “normal” beans.

If you want to get the URL of the Page, this is something CORE php can do for you.

$_SERVER[‘HTTP_HOST’] and $_SERVER[‘REQUEST_URI’];

a URL is a php thing,
just do it this way

https://www.php.net/manual/en/ref.url.php