Counter

Help
Robert
2011-06-14
2013-04-25
  • Robert
    Robert
    2011-06-14

    I'm working with this formula but I'm using it in a computed on creation field formula instead of in a createDocument event, but I'm having errors.

    - create form frmCounter, with an editable numeric field (counter)
    - create a view (counterview) to list frmCounter docs
    - create one doc with this form and enter the initial counter value (0)
    then in your main form, add a formula in the onCreateDocument event:
    counterdoc=plominoDocument.getParentDatabase().getView("counterview").getAllDocuments().getObject()
    newvalue=counterdoc.counter+1
    counterdoc.setItem("counter", newvalue)
    counterdoc.save()
    return newvalue

     
  • Robert
    Robert
    2011-06-14

    This is my log using Closseau:

    001 >>> plominoContext = context

    002 >>> plominoDocument = context

    003 >>> from Products.CMFPlomino.PlominoUtils import DateToString, StringToDate, DateRange, sendMail,  
                            userFullname, userInfo, htmlencode, Now, asList, urlencode, csv_to_array, MissingValue, open_url,
                            asUnicode, array_to_csv

    004 >>> counterdoc=plominoDocument.getParentDatabase().getView("counterview").getAllDocuments()
                            .getObject()

               Traceback (most recent call last):
    005         File "<input>", line 1, in <module>
               AttributeError: 'NoneType' object has no attribute 'getAllDocuments'

    006 >>> newvalue=counterdoc.counter+1

             Traceback (most recent call last):
    007       File "<input>", line 1, in <module>
             NameError: name 'counterdoc' is not defined

    008 >>> counterdoc.setItem("counter", newvalue)

                Traceback (most recent call last):
    009          File "<input>", line 1, in <module>
                NameError: name 'counterdoc' is not defined

    010 >>> counterdoc.save()

               Traceback (most recent call last):
    011         File "<input>", line 1, in <module>
               NameError: name 'counterdoc' is not defined

    012 >>> newvalue

                 Traceback (most recent call last):
    013           File "<input>", line 1, in <module>
                 NameError: name 'newvalue' is not defined

     
  • Eric Brehault
    Eric Brehault
    2011-06-16

    >>> counterdoc=plominoDocument.getParentDatabase().getView("counterview").getAllDocuments()
    AttributeError: 'NoneType' object has no attribute 'getAllDocuments'

    it just means the "counterview" view does not exist
    check the id is correct.

    Eric