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

MFIdentifier : Vault element with the alias "CL.Coexya.RH.MTAM.DemandeMtam" is not found.

Hello,

I am getting errors after adding new MFidentifiers to my code. I am probably not understanding when it's instanciated. The code is simple: 

public class VaultApplication
        : MFiles.VAF.Extensions.ConfigurableVaultApplicationBase<Configuration>
    {
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropMatricule = "PD.Matricule";
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropEmail = "M-Files.UserSynchronization.Email";
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropCommentaires = "PD.Commentaires";
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropCommentaire = "PD.Commentaire";
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropActeur = "PD.Coexya.RH.ActeurDuWorkflow";
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropEtapeAvant = "PD.EtapeAvant";
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropResolution = "PD.Coexya.RH.Resolution";
        [MFPropertyDef(Required = true)]
        MFIdentifier mfIdPropResolutions = "PD.Coexya.RH.Resolutions";

        [MFClass(Required = true)]
        MFIdentifier mfIdClassDemandeSAOexterne = "CL.Coexya.RH.SAO.DemandeSaoExterne";
        [MFClass(Required = true)]
        MFIdentifier mfIdClassDemandeSAOinterne = "CL.Coexya.RH.SAO.DemandeSaoInterne";
        [MFClass(Required = true)]
        MFIdentifier mfIdClassDemandeMtam = "CL.Coexya.RH.MTAM.DemandeMtam";
        
        [...]
        
        [EventHandler(MFEventHandlerType.MFEventHandlerBeforeCheckInChangesFinalize, Priority = 1, FilterOptions = MFEventFilterOptions.IgnoreTemplates)]
        public void BeforeCheckInChangesFinalize(EventHandlerEnvironment env)
        {
            [...]

            //class MTAM = 0
            if(currentObject.Class == (int)mfIdClassDemandeMtam || currentObject.Class == (int)mfIdClassDemandeSAOexterne || currentObject.Class == (int)mfIdClassDemandeSAOinterne)
            {
                commentairePropertyID = (int)mfIdPropResolution;
                commentairesPropertyID = (int)mfIdPropResolutions;
                acteurPropertyID = (int)mfIdPropActeur;
                etapeAvantPropertyID = (int)mfIdPropEtapeAvant;
            }

I am getting the error when the first MFidentifiers is used. ((int)mfIdClassDemandeMtam) . If I put the ID , then of course it works but it stop to next mfidentifier ((int)mfIdPropResolution).

mfIdPropMatricule and mfIdPropEmail are working fine in another function. There are the first added to my app.

A collleague and me crosscheck that thoses aliases are in the correct vault. We copied the aliases form the vault to visual studio.

Any hint?

Thanks, 

Amaury

Parents Reply Children
  • Yes, or grab its ID:

    var id = this.Configuration.MyIdentifier.ID;

    The MFIdentifier class has lots of other useful properties, such as IsResolved, that may be used for gatekeeping certain parts of logic, or for throwing exceptions if misconfigured.

    I'd also highlight that you should add [DataMember] and [MFPropertyDef] attributes to the configuration elements so that they get exposed in the M-Files Admin.  That'll allow you to easily reconfigure them if needed.

    It may be worth reaching out to the Channel team who run periodic training on the VAF.  Some of this is covered directly, and they'd be more than happy to help talk you through best practices during the training.

  • Thank you.

    Wasn't clear for me that MFidentifier HAVE TO BE declared in the configuration

  • You can declare them outside, but they will not be automatically resolved.  It's best to place them in the configuration.

  • Sorry Craig but I have another question on the same topic Slight smile

    What could cause the no resolution of the MFIdentifier in the configuration class? it looks like that:

    using MFiles.VAF.Configuration;
    using System.Runtime.Serialization;
    
    namespace client.vem
    {
        [DataContract]
        public class Configuration : MFiles.VAF.Extensions.Configuration.ConfigurationBase
        {
    
            //PROPERTIES
            [DataMember]
            [MFPropertyDef(Required = true)]
            public MFIdentifier mfidPDLogiciel = "MF.PD.LOGICIEL"; 
            [DataMember]
            [MFPropertyDef(Required = true)]
            public MFIdentifier mfidPDIDGed = "MF.PD.IDGED";
            
            [...]

    thank you?

  • In your code, if you reference "this.Configuration.mfidPDIDGed.ID", what does this resolve to?  -1?  Is there a property in your vault with that alias?

  • Hah, I realised that something I am using actually solves this problem.

    The issue is that your code adds that the property definition is required, but in the JSON configuration it's empty.

    If you are assigning a default value and you want your code to test whether it's valid then you can state that in your code:

    		[DataMember]
    		[MFPropertyDef(AllowEmpty = true)]
    		public MFIdentifier mfidPDIDGed = "MF.PD.IDGED";