# How to get Test Plan External Parameters for Test Step before running

**URL:** <https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438>\
**Category:** Technical\
**Created:** [August 26, 2021, 1:24pm UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438 "2021-08-26T13:24:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![juhani.tormanen](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@juhani.tormanen](https://forum.opentap.io/u/juhani.tormanen)\
**Post date:** [August 26, 2021, 1:24pm UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/1 "2021-08-26T13:24:49Z")

</div>

Hi everyone, I’m currently developing test step which needs to list all available external parameters from test plan settings for user to select from combo box. So far I’ve only managed to do this in PrePlanRun/Run phases. How would it be/is it possible to load these external parameters when test plan is loaded, test step is added to the test plan and test step is selected in the test plan?

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [August 27, 2021, 6:32pm UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/2 "2021-08-27T18:32:55Z")

</div>

Hi @juhani.tormanen, and welcome!

So it sounds like you’ve already developed a function which lists the external parameters as desired, and that function works when called from PrePlanRun and Run, correct?

Can you stick that same function into the getter of a List which is used by an AvailableValues attributed property? Something like this:

```csharp
[xmlignore]
public List<string> AvailableExternalParams
{
  get
  {
    return GetAllExternalParams();
  }
}

[AvailableValues(nameof(AvailableExternalParams))]
public List<string> SelectedExternalParams {get;set;}

```

---

<div class="post-metadata">

**Author:** ![juhani.tormanen](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@juhani.tormanen](https://forum.opentap.io/u/juhani.tormanen)\
**Post date:** [September 21, 2021, 1:06pm UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/3 "2021-09-21T13:06:32Z")

</div>

Thanks, this code example did the trick 😊

---

<div class="post-metadata">

**Author:** ![teder.ted](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@teder.ted](https://forum.opentap.io/u/teder.ted)\
**Post date:** [April 4, 2023, 7:14am UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/4 "2023-04-04T07:14:00Z")

</div>

Hi  
Would you please show me how to change and save an external parameter of a test plan in code?  
I can get the list of parameters from ExternalParameters.Entries of a loaded testplan but this list is read only.  
Is there any API to save edited ExternalParameters to the test plan? However I can manually open testplan file (.TapPlan) and edit xml file.

---

<div class="post-metadata">

**Author:** ![btyilmaz](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@btyilmaz](https://forum.opentap.io/u/btyilmaz)\
**Post date:** [April 4, 2023, 11:07am UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/5 "2023-04-04T11:07:12Z")

</div>

Hi @teder.ted

I am not sure this is what you want but you can get the parameter you want from ExternalParameters.Entries list. Then you can edit its value.

Following code is inside a test step’s Run() method. Time Delay is the name of the parameter and its value can be set. To save it though, you need to save the test plan by calling TestPlan.Save().

```csharp
var parameterList = ((TestPlan)this.Parent).ExternalParameters; // Get ExternalParameters
var parameter = parameterList.Get("Parameters \\ Time Delay"); // Get specific parameter by its name
parameter.Value = 5; // Edit value

```

---

<div class="post-metadata">

**Author:** ![teder.ted](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@teder.ted](https://forum.opentap.io/u/teder.ted)\
**Post date:** [April 5, 2023, 7:55am UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/6 "2023-04-05T07:55:47Z")

</div>

Thanks  
calling testPlan.Save() cause this error:  
Method not found: ‘System.collections,generic.IEnumerable’1\<System.String\> OpenTap.TapSerializer.GetUsedFiles()’

---

<div class="post-metadata">

**Author:** ![btyilmaz](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@btyilmaz](https://forum.opentap.io/u/btyilmaz)\
**Post date:** [April 5, 2023, 8:32am UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/7 "2023-04-05T08:32:35Z")

</div>

I works fine in my test step. Can you clean the solution and run it again? Multiple assemblies containing the same method inside the project output may cause this issue.

If that doesn’t work can you give more information? Where do you call the Save() method, is the error occurs during runtime or compilation?

---

<div class="post-metadata">

**Author:** ![teder.ted](https://avatars.discourse-cdn.com/v4/letter/t/8491ac/32.png) [@teder.ted](https://forum.opentap.io/u/teder.ted)\
**Post date:** [April 8, 2023, 10:25am UTC](https://forum.opentap.io/t/how-to-get-test-plan-external-parameters-for-test-step-before-running/438/8 "2023-04-08T10:25:15Z")

</div>

> [@btyilmaz](#):
>
> Can you clean the solution and run it again? Multiple assemblies containing the same method inside the project output may cause this issue.

Thanks, that’s the point. I clean the project and delete all assemblies and just worked!
