# How can I use a local variable to bring out a method extension?

**URL:** <https://www.dynamicsuser.net/t/how-can-i-use-a-local-variable-to-bring-out-a-method-extension/86348>\
**Category:** Developer Forum\
**Tags:** d365fo\
**Created:** [November 14, 2024, 2:36pm UTC](https://www.dynamicsuser.net/t/how-can-i-use-a-local-variable-to-bring-out-a-method-extension/86348 "2024-11-14T14:36:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![devtoichoi](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@devtoichoi](https://www.dynamicsuser.net/u/devtoichoi)\
**Post date:** [November 14, 2024, 2:36pm UTC](https://www.dynamicsuser.net/t/how-can-i-use-a-local-variable-to-bring-out-a-method-extension/86348/1 "2024-11-14T14:36:30Z")

</div>

As mentioned, I want to reuse a locally declared variable and use its value in the extension method.

Example

```auto
protected boolean checkTaxCodesByLine()
{
    TaxCode lastTaxCode;
    lastTaxCode = taxWorkTrans.TaxCode;
}

```

Extension method

```auto
public TaxTable taxTable;
protected boolean checkTaxCodesByLine()
{
    next checkTaxCodesByLine() ;
    taxTable = this.getTaxTable(lastTaxCode);

    return true;
}

```

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [November 14, 2024, 3:50pm UTC](https://www.dynamicsuser.net/t/how-can-i-use-a-local-variable-to-bring-out-a-method-extension/86348/2 "2024-11-14T15:50:57Z")

</div>

It’s not possible. The variable is both created a ceased to exist inside the call of `next checkTaxCodesByLine()`, therefore it simply doesn’t exist in any of your code.
