Importing selections from CSV

Developers
2010-08-23
2013-04-25
  • Is it currently possible to import fields that allow multiple selection?

    <document>.setItem requires a list, but always gets a string in importCsv

    It looks like the form's processInput may be a more appropriate API to call, otherwise other fields will also give problems.

     
  • Eric Brehault
    Eric Brehault
    2010-09-06

    Hello,

    indeed, you cannot import multivalued fields directly
    but after impor, you can use a small Plomino agent to split the string value and store an array
    let's assume your multivalued field is named "field1" and you use '|' as value separator, it would something like that:

    db=plominoContext.getParentDatabase()
    for doc in db.getAllDocuments():
      if doc.hasItem("field1"):
        v = doc.field1
        # is it a list ?
        if hasattr(v, 'append'):
          doc.setItem("field2", v.split("|")
          doc.save()

    eric

     
  • Jean Jordaan
    Jean Jordaan
    2010-09-07

    You'd have to run an agent for all numbers, date-times .. all non-string fields .. which makes import from CSV less useful than it need be. The incoming data looks a lot like the data you get from form submission. Isn't it possible to treat it the same and get more useful CSV import?

     
  • Eric Brehault
    Eric Brehault
    2010-09-10

    yes good idea, and that's probably quite easy to do I think