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

Script to create documents via barcode

I've got a couple of different classes of document that I'm looking at automatically importing into M-Files via the File Source arrangement.

The idea I had, after seeing all the posts about using barcodes to locate existing documents in M-Files and updating them, or to add barcodes to existing documents, was to configure the barcode with appropriate information, including a Class Identifier, and have M-Files handle it.

Where I'm stuck, is that I'm not sure where the script should go (i.e. event handler, workflow with automatic state transition, other?), as I want M-Files to automatically create new documents based on the details in the barcode.

My intention was to use a compound barcode, i.e. DocClass-JobID-ClientID, and parse the values into appropriate properties, as the values are used in M-Files as external IDs anyway. Documents would have the barcode automatically generated by the external software, for use as automatic entry into M-Files.
As I understand it, the Importer can deal with single value barcodes (or OCR text values, for that matter), but since I want to preset the document type and the other information in the barcode, I don't know whether a workflow, event handler or similar would be the appropriate place for it. I've got workarounds available (separate file import tool per document class, reading from a separate folder, as an example) but would really prefer to be able to parse the barcode, set the document class and properties, and be done.

Any suggestions?
Parents
  • Thank you to both of you.

    djb has provided a couple of subtleties that I'd missed when first testing this solution, that I'll highlight here in case anyone else gets stuck:
    [list type=decimal]
    • Only SetAllProperties can change the class of the object, I'd been getting errors in using the other methods (SetProperty, SetProperties) previously

    • SetAllProperties needs the SingleFile property to be included in the collection, and appropriately set

    [/list]
    This is obvious in hindsight, along with the fact that since the method is SetAllProperties, all the relevant properties for the class being changed to need to be set, including whatever the default Name property is.

    djb, I also appreciate the suggestion about using the filename as data entry instead, although I won't be doing that in my case as I can automatically configure the barcode contents, I can't do that with the file name as it requires the user to enter the filename manually.
Reply
  • Thank you to both of you.

    djb has provided a couple of subtleties that I'd missed when first testing this solution, that I'll highlight here in case anyone else gets stuck:
    [list type=decimal]
    • Only SetAllProperties can change the class of the object, I'd been getting errors in using the other methods (SetProperty, SetProperties) previously

    • SetAllProperties needs the SingleFile property to be included in the collection, and appropriately set

    [/list]
    This is obvious in hindsight, along with the fact that since the method is SetAllProperties, all the relevant properties for the class being changed to need to be set, including whatever the default Name property is.

    djb, I also appreciate the suggestion about using the filename as data entry instead, although I won't be doing that in my case as I can automatically configure the barcode contents, I can't do that with the file name as it requires the user to enter the filename manually.
Children
No Data