Version Control Lite - Ask user to create new version when drag and drop document

Hi Craig,

I am looking at possibly extending the functionality in the Version Control Lite module of the Compliance Kit by building a VAF/UIX application. I am specifically looking to somehow prompt the user if they want to “Create a New Version” if that user attempts to drag and drop a file onto a controlled document in the released/published workflow state. We are trying to avoid the need for the user to create a new version of the document first before dragging and dropping a file onto the document. If this is something that is feasible in your mind, I would appreciate a quick overview of how I would build that so I am not spinning my wheels for too long. 

thanks,

Jack Dawson

Parents
  • Hi Craig,

    Is there an event that would allow me to fire off code in a VAF when a file is dragged onto an existing document?

    Thanks,

    Jack

  • From a server perspective, the server/VAF don't understand that a document was dragged onto an existing document.  The events that are raised simply indicate that the object was updated.  That update could have come from an API call, the object being checked out/in, etc.

    I don't think that an explicit event is fired for this in the UIX either; the only hits related to dragging/dropping in the documentation refer to events inside dashboards, not in listings.

  • What if I were to trigger my code from a BeforeFileUpload event? I was thinking that my code could validate some properties to confirm that the document is a "controlled document" and then send a prompt to the user asking if they want to "create a new version" to which the user can say yes or no. If they say yes, then it would move the document to a new workflow state and then complete the file upload. Does this sound like a workable solution?

  • I don't think that's possible, for a couple of reasons.

    Firstly: based on this documentation: https://userguide.m-files.com/user-guide/latest/eng/Event_handlers_variables.html.  Note that in the available variables it does not include anything about the object that the file is being uploaded to, so I am not sure that you'll actually be able to check whether it's a controlled document or not.

    Secondly: even if it were, there's no way to prompt the user to confirm something at this point.  You can throw an exception (which should stop everything), but there's no way for them to confirm that this is something they want to do.

  • Craig,

    I have been able to get a lot of this functionality working through UIX by using the OnAddObjectFile event which is passed an objVer object as a parameter. I used the ConfirmWorkflowStateChange sample in GitHub as the starting point and registered the OnAddObjectFile event. Since this event fires before the actual add object file operation is successfully completed, is it possible/acceptable to check-out the document, modify the workflow state, and check the document back in before returning true to allow the file upload to complete?

  • Sorry, I was travelling last week.

    I am not sure that I have tried that.  The callback receives an object version that you could use to communicate with the vault, but I'm unsure whether it'll be happy for the object to be checked out and in again (i.e. the version to be changed) during the callback.

    My gut instinct is that it won't work, although it sounds like you're quite far down this route so did you try it?

  • I have tried many different options for this solution but none have given me exactly what I need. For example, the OnAddObjectFile event worked perfectly for multfile documents but never triggers for single file documents (makes sense I guess since you are replacing files in a single file document and not adding a file). I figured out another option using the OnCheckInObject event which works great for both MFD and SFD, especially when you forget and only test your code with an administrator user account and not a user account, but I ran into an issue because the controlled documents have "locked" permissions. I was also looking at the OnBuiltinCommand event, but it does not have an object version callback so I am not sure if there is anything I can do here either. 

    I am very close but none of my attempts have been completely successful yet, but I haven't given up!

Reply
  • I have tried many different options for this solution but none have given me exactly what I need. For example, the OnAddObjectFile event worked perfectly for multfile documents but never triggers for single file documents (makes sense I guess since you are replacing files in a single file document and not adding a file). I figured out another option using the OnCheckInObject event which works great for both MFD and SFD, especially when you forget and only test your code with an administrator user account and not a user account, but I ran into an issue because the controlled documents have "locked" permissions. I was also looking at the OnBuiltinCommand event, but it does not have an object version callback so I am not sure if there is anything I can do here either. 

    I am very close but none of my attempts have been completely successful yet, but I haven't given up!

Children
No Data