convert months name into Roman numbers

nodeen
nodeen Member
edited September 13 in Extended ECM Integration #1

Hello,

I have the following requirements:

  1. Convert the names of months into Roman numerals. The only solution I could think of is using web reports. Can anyone provide me with a sample script for this?
  2. Generate an auto number (1, 2, 3...) in a workflow attribute. I found an attribute type called ADN Reference & ADN table Key Lookup, but unfortunately, these ADN functions only work for XECM Engineering. I only have XECM installed on my server. Can anyone provide a workaround for this?

Regards,

Novi

Answers

  • Hi,

    Your use case isn’t entirely clear, but my recommendation is to work on the backend rather than the frontend. If you implement the conversion on the frontend with JavaScript, you’re relying on the browser, which isn’t something you can control 100%. If you have AnswerModules' ModuleSuite available, you can write code similar to the following in the Content Script controller of your Beautiful WebForms:

    def monthToRoman = [
        "January": "I", "February": "II", "March": "III", "April": "IV",
        "May": "V", "June": "VI", "July": "VII", "August": "VIII",
        "September": "IX", "October": "X", "November": "XI", "December": "XII"
    ]
    
    def convertMonthsToRoman(monthNames) {
        monthNames.collect { monthToRoman[it] ?: "Invalid month" }
    }
    

    By doing this, you can ensure that the code is executed exactly how, when, and where you want (and you won’t need to rely on OScript and you don't even have to deploy anything).

    The same applies for the incremental ID. ADN is available only in certain flavors of xECM, and if you don’t have it, you can create a field based on a value stored in the database and increment it using backend mechanisms (again, with very simple ContentScript). These mechanisms would account for race conditions, simultaneous access, and all best practices for parallel access to the same unique resource by different threads.

    Once again, if you handle this on the frontend, it’s a sure recipe for disaster.

    Jacopo Malnati

  • This would require a change to the code formatters, if you trace the code from ?func=admin.dateformat you can find where the formats are used and then trace them to where they are used in the utils methods.