This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How can I reference the Configuration from CustomDomainCommand Header button?

I'm attempting to use the Header button from

https://developer.m-files.com/Frameworks/Vault-Application-Framework/Configuration/Commands/

But I am unable to reference the variables obtained from the Configuration editors

https://developer.m-files.com/Frameworks/Vault-Application-Framework/Configuration/Editors/

Example below, would expect the MyStringValue from the config to end up in the popup, but the typical this.Configuration.<> doesnt seem to work in this instance.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public class VaultApplication
: MFiles.VAF.Extensions.ConfigurableVaultApplicationBase<Configuration>
{
public readonly CustomDomainCommand cmdHeaderButtonCommand = new CustomDomainCommand
{
ID = "cmdHeaderButtonCommand",
Execute = (c, o) =>
{
string returntest = this.Configuration.MyStringValue;
o.ShowMessage(""+returntest);
},
DisplayName = "Test Contents",
Locations = new List<ICommandLocation>
{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Parents
  • This isn't related to the VAF at all, but how fields instantiated like that can access instance members.  Instead: move the code to the constructor:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    public class VaultApplication
    : MFiles.VAF.Extensions.ConfigurableVaultApplicationBase<Configuration>
    {
    public CustomDomainCommand cmdHeaderButtonCommand { get; }
    public VaultApplication()
    {
    this.cmdHeaderButtonCommand = new CustomDomainCommand
    {
    ID = "cmdHeaderButtonCommand",
    Execute = (c, o) =>
    {
    string returntest = this.Configuration.MyStringValue;
    o.ShowMessage(""+returntest);
    },
    DisplayName = "Test Contents",
    Locations = new List<ICommandLocation>
    {
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    An alternative approach is to use the new functionality recently added to the Extensions, which cuts out a lot of that boilerplate:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    public class VaultApplication
    : MFiles.VAF.Extensions.ConfigurableVaultApplicationBase<Configuration>
    {
    [CustomCommand("Test Contents")]
    [ButtonBarCommandLocation]
    public void SayHello
    (
    IConfigurationRequestContext context,
    ClientOperations operations
    )
    {
    string returntest = this.Configuration.MyStringValue;
    operations.ShowMessage(""+returntest);
    }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Thank you! and the new functionality is beautifully simple.

  • It doesn't do anything more clever than plumb together everything via those attributes.  The VAF does all the hard work.

    Glad it's working though.

  • I had a secondary issue which drove the original question where I had a second class in the main namespace.  was trying to pull in from the configuration class.  I solved that issue by passing "this.Configuration" through to that class as "Configurat Config" and then i could just Config.<> without problems!

Reply
  • I had a secondary issue which drove the original question where I had a second class in the main namespace.  was trying to pull in from the configuration class.  I solved that issue by passing "this.Configuration" through to that class as "Configurat Config" and then i could just Config.<> without problems!

Children
No Data