How to migrate Link Fields ('title' and 'url') involving local variables? I have performed the following query:

$query = db_select('sage.USER', 'USER')
  -&gt;fields('USER', array('USER_ID', 'OFFICE_ID', 'USER_PASSWORD'))
  -&gt;range(0, 1);
$result = $query-&gt;execute();
...
$url = '/sage/office-' . $result-&gt;office_id;
$arguments = MigrateLinkFieldHandler::arguments(array('source_field' =&gt; 'office_id'));
$this-&gt;addFieldMapping('field_office_id', $url);
  -&gt;arguments($arguments);


However, the above is not working. I would like to manipulate the 'office_id' field to be used as the 'title' and the variable $url to be used as the URL that was linked. I have followed what's on this post

Could someone please point out my mistakes?

EDIT: Updated question to reflect jdu's answer.
The link.migrate.inc file is not included in the Migrate Extras module, it's part of the Link module.

The file doesn't exist in the stable version of Link, but it does exist in the dev release. I think you're going to have to install the dev version of Link if you want this to work.

If you install the dev version and still get the error it's most likely because the file is not being automatically included. If that's the case try adding this to the top of your code:

module_load_include('inc', 'link', 'link.migrate');


EDIT

As I mentioned in your other question there's a slight error in your code, you should change this line:

$result = $query-&gt;execute();


to:

$result = $query-&gt;execute()-&gt;fetchObject();


That will return an object representing the first result that was returned by the query.