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

Intelligent Metadata Layer/External Repository Connectors

Hi, 

I am developing External Repository Connectors which help to synchronize data from one of the accounting software.

I know that we have one method called "OpenConnection" which opens the connection and gets the connection string.
"public IDataSourceConnection OpenConnection(string connectionString, Guid configurationId)"

Is there any way to actually read the connection string and update it to whatever we want?

Also, how do we map the value list properties of m-files in GetItems method?

Thank You,

Yash

  • Hi Yashkumar,

    I assume that you're implementing an IML-based external object type data source, not an external repository connector?

    Is there any way to actually read the connection string and update it to whatever we want?

    I guess that you could read the string and do something else in your code, or do you want to update the saved value?  What's the use-case here?  

    Also, how do we map the value list properties of m-files in GetItems method?

    You need to return the IDs of the value list items.  The concept here is that the remote system - if it's providing values for the objects - should know those IDs, as typically the value list also comes from that remote system too.

  • I guess that you could read the string and do something else in your code, or do you want to update the saved value?  What's the use-case here?  

    Yes, I need to update the saved value. any method for that ?


    Also, can we access the vault variable and its methods, if yes, How?
  • The external object type connectors are designed to be configured by the admin, then their role is to proxy data from the remote system into structures that M-Files can import.  There are no explicit methods for updating the configuration, nor interacting with the vault contents, via the external object type connector.

    Can you describe the use-case?  What exactly are you trying to do here?  Why do you want to do this?

  • Well in the connection string of the external source, I am providing one token which needs to get refreshed every hour, so when I do refresh, I need to store the updated token back to the connection string, for future use, if I store the token locally then when the vault restarts for any reason, I lose the value of update token.

  • I can understand that.

    In the "DataSource.cs" file, there's a method named "OpenConnection".  This instantiates a DataSourceConnection.

    You could alter this so that you pass a reference to the datasource into the connection.  I believe that this has a permanent vault reference (datasource.VaultApplication.ApplicationContext.PermanentVault) which can be used to access the vault.

    Using this reference you could access NVS and set/read the value.

  • Datasource only have OpenConnection() and CanAlterData() method it doesn't have (datasource.VaultApplication.ApplicationContext.PermanentVault).

    could you provide me some code ?


    Thank You,

    Yash

  • In DataSource.cs:

    /// <summary>
    /// Open External Object Type Connection.
    /// </summary>
    /// <param name="config">Configuration</param>
    /// <param name="stopToken">Stop token.</param>
    /// <returns>External Object Type Connection</returns>
    public override IExternalObjectTypeConnection OpenConnection(
    	ExternalObjectTypeConfiguration<ConfigurationRoot> config,
    	CancellationToken stopToken
    )
    {
    	// Instantiate our data source connection.
    	return new DataSourceConnection( this, config, stopToken );
    }

    In DataSourceConnection.cs:

    /// <summary>
    /// Instantiates a DataSourceConnection for a specific data source.
    /// </summary>
    /// <param name="config">The configuration.</param>
    /// <param name="stopToken">Stop token.</param>
    public DataSourceConnection(
        DataSource dataSource,
        ExternalObjectTypeConfiguration<ConfigurationRoot> config,
    	CancellationToken stopToken
    ) : base( config, stopToken )
    {
    	// Set.
    	this.Config = config;
    			
    	// Access the named value storage.
    	dataSource.ApplicationContext.PermanentVault.NamedValueStorageOperations...
    }

    Note: I haven't checked that these items have runtime values, just that there was a vault reference in intellisense that you could use.  You will need to debug these to see whether they work as expected.

  • I am using  MFIles.Server.Extension (1.12.0.0), that don't have PermanentVault,
    Is there any other latest version ?

  • If you're using the latest version of the Visual Studio template package then the created project should reference those DLLs from nuget, not from the filesystem.  The current release of the template package creates a project that references the 21.6.12 builds of those items, I think.

  • I was not using the Visual Studio Template, I was following the documentation of the M-Files developer site, There they don't say about using a template.

    I could see now that the implementation in the template is different than the documentation, Is there any other documentation that follows that shows how to start with a template?