The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.

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

C# : Set a default value for MFIdentifier in Configuration

Hello, 

In a VAF application, I want to show the MFidentifier in configuration panel. But I can't make the default value work. It's always marked as error. For example:

[DataMember]
[MFPropertyDef(Required = true)]
public MFIdentifier mfIdPropActeur = "PD.SOCLE.Acteur";

[DataMember]
[MFPropertyDef(Required = true)]
[JsonConfEditor(DefaultValue = "PD.SOCLE.Action")]
public MFIdentifier mfIdPropAction = "PD.SOCLE.Action";

The question is simple : how to make work? How to specify 

Thanks,

Amaury Bianchi

Parents
  • Hello,

    I have additional issues. When I first deploy my app, all the datamember are red in the admin, but raise no error.

    But if I complete one and save, then all the oters are now in error.

    They are declared like that: 

    [DataMember]
    [MFPropertyDef]
    [JsonConfEditor(DefaultValue = "M-Files.UserSynchronization.Email")]
    public MFIdentifier mfIdPropEmail = "M-Files.UserSynchronization.Email";
    
    [DataMember]
    [MFPropertyDef]
    [JsonConfEditor(DefaultValue = "PD.EtapeAvant")]
    public MFIdentifier mfIdPropEtapeAvant = "PD.EtapeAvant";
    
    [DataMember]
    [MFPropertyDef]
    [JsonConfEditor(DefaultValue = "PD.Coexya.Service")]
    public MFIdentifier mfIdPropService = "PD.Coexya.Service";
    
    [...]

    Adding a "(Validate = false)" tag change nothing....

    How to make a proper configuration in this case?

    I juste want to show the alias with default values and be able to some of them if necessary.

    Thank you

  • In the example I linked to earlier, it showed how to make one property optional.  You don't seem to have used the AllowEmpty property that the example does.

    Editors (m-files.com)

  • What a fast answer !

    I am sorry for missing that, I was reluctant to use that tag because it allow the user to put nothing then save... But that's better than errors.

    I have another question about this. What does this tag do?

    I didn't really understood.

  • I am sorry for missing that, I was reluctant to use that tag because it allow the user to put nothing then save... But that's better than errors.

    But that's the reason why you validate your configuration at runtime.

    The attribute you linked to is part of the dotnet BCL, not directly related to VAF development: DataMemberAttribute Class (System.Runtime.Serialization) | Microsoft Learn

    It is used to define that a member should be serialized to the serialized representation (JSON, in this case) of the object.  There's more information on what it does in the documentation.

Reply Children
No Data