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 to prevent user from changing files of a document

We have a workflow where users can import receipts in M-Files and they are approved by several persons depending on the metadata. Changes of the files should not be allowed, but information is filled in the metadata during the workflow. The only solution I have found to prevent changes of the document files, is to check with a script in the AfterCheckInChanges event handler. The script checks if the files of the document have changed since the last version.
Dim objFiles: Set objFiles = Vault.ObjectFileOperations.GetFiles(ObjVer)
' During the creation of the object no test is necessary
if ObjVer.Version > 1 then
' Getting files of previous version
Dim ObjVerOld: Set ObjVerOld = ObjVer.Clone()
ObjVerOld.Version = ObjVerOld.Version-1
Dim objFilesOld: Set objFilesOld = Vault.ObjectFileOperations.GetFiles(ObjVerOld)

' If count of files differ then raise exception
if objFiles.Count <> objFilesOld.count then
Err.Raise MFScriptCancel, "Es k?nnen keine Dateien hinzugef?gt oder entfernt werden!"
end if

Dim found
For index = 1 To objFiles.Count
' If a file has a version greater 1 then it was changed => raise exception
if objFiles.Item(index).FileVer.Version <> 1 then
Err.Raise MFScriptCancel, "Es k?nnen keine Dateien ver?ndert werden!"
end if

' If the GUID of the file has changed then the file was replaced => raise exception
found = false
For indexOld = 1 To objFilesOld.Count
if objFiles.Item(index).FileGUID = objFilesOld.Item(indexOld).FileGUID then
found = true
Exit for
end if
Next
if found = false then
Err.Raise MFScriptCancel, "Es k?nnen keine Dateien ausgestauscht werden!"
end if
Next
end if

Is this the recommended solution or is there a simpler way to achive this behaviour?
Thanks for the help.
Parents

  • Unfortunately we cannot install the script ourselves because it is on a cloud server and scripts can only be installed via our reseller.

    Is this normal for a cloud installation? Would it be better to run M-Files on premise?
    But as 90% of our users are using M-Files externally, we would need to run M-Files on our own public server, therefore we would need to take care of security and backup ourselves.


    If you are hosted on M-Files Cloud then all custom scripts and vault applications need to be currently validated and installed by M-Files due to security and performance reasons, more information on the validation process on our Developer Portal. We are in the process of moving our cloud customers to a new cloud platform and when migrated customers will have the option for an Isolated Service add-on which will enable you to install and manage these scripts and vault applications yourself.

    If you are hosted on your reseller's own cloud infrastructure then these policies are up to them but I think it's quite common not to allow installation of custom scripts, especially on multi-tenant servers where multiple customers are hosted.

    In the end you need to weigh the pros and cons of the hosting options for your business: the ease of cloud hosting (with included high availability, automatic backups, platform maintenance, security etc.) vs. full control of the environment in your own datacenter.
Reply

  • Unfortunately we cannot install the script ourselves because it is on a cloud server and scripts can only be installed via our reseller.

    Is this normal for a cloud installation? Would it be better to run M-Files on premise?
    But as 90% of our users are using M-Files externally, we would need to run M-Files on our own public server, therefore we would need to take care of security and backup ourselves.


    If you are hosted on M-Files Cloud then all custom scripts and vault applications need to be currently validated and installed by M-Files due to security and performance reasons, more information on the validation process on our Developer Portal. We are in the process of moving our cloud customers to a new cloud platform and when migrated customers will have the option for an Isolated Service add-on which will enable you to install and manage these scripts and vault applications yourself.

    If you are hosted on your reseller's own cloud infrastructure then these policies are up to them but I think it's quite common not to allow installation of custom scripts, especially on multi-tenant servers where multiple customers are hosted.

    In the end you need to weigh the pros and cons of the hosting options for your business: the ease of cloud hosting (with included high availability, automatic backups, platform maintenance, security etc.) vs. full control of the environment in your own datacenter.
Children
No Data