The Hack-tastic Hookup

So, the other day, I blogged about a problem with ComputeWithForm in LotusScript. Many of you feel that ComputeWithForm was the hack, rather than the workarounds, which is fine and dandy. However, if you have an application that already uses ComputeWithForm and you’re having issues, head over to Julian’s blog to get the tool he created to help find what is causing the failure.

An interesting note, I used the tool and found that I was getting an error on a field that had the following (admittedly poorly written) @Formula in input translation: @Date(@ThisValue). Of course, the formula should have been: @If(@thisvalue = “”; “”; @Date(@ThisValue)). However, the first formula still worked on the front-end document. If the field was blank, the doc still would refresh and save without error. BUT, if the field was blank, it was causing ComputeWithForm to fail. I was able to discover that, thanks to Julian’s ComputeWithForm tool.

My original problem had nothing to do with the field I wanted recalculated, but another field altogether.

Thanks Julian!

  • http://nathan.lotus911.com Nathan T. Freeman

    Ummm… what if the value for the field is “December?” or “kumquat” : “kumall”? or 4:8:15:16:23:42?

    There are an awful lot of failure conditions left available. Might I suggestion you make the translation formula assert that the value is a valid date, and protect itself by resolving to @Unavailable if it’s blank for if it fails.

    Otherwise you’re deliberately populating values in the field with mixed data types across multiple documents. Sometimes it’s TEXT and sometimes its TIME/DATE.

  • http://nathan.lotus911.com Nathan T. Freeman

    *might I SUGGEST, sorry… grammar fail. Emoticon

  • http://nathan.lotus911.com Nathan T. Freeman

    lol. And I can’t believe it skipped my mind, but your translation formula should now throw errors IF THERE REALLY IS A DATE in the field. Because TimeDate = “” will error with a type mismatch every time.

  • http://www.runningnotes.net Kathy Brown

    @Nathan – I believe you are missing the point. I said it was crap coding, the point was that ComputeWithForm seemed to be enforcing a stricter validation than the front-end doc. The point was not how to write a proper translation formula. Emoticon

  • http://nathan.lotus911.com Nathan T. Freeman

    Now you’re missing my point. By relying on input translation via ComputeWithForm, you’re opening yourself up to a whole slew of possible failure conditions that will be almost impossible to track. Your computeWithForm will now break on any document that has a legitimate date in that field, for instance.

    It’s just a case study in why the method is bad news. Even when you know exactly what the problem is, your fix isn’t really going to fix it, and you’re going to go right back to “why the hell doesn’t this work NOW?”

  • http://www.runningnotes.net Kathy Brown

    And the field incidentally validated just fine with a date. And it errored when I input “kumquat”, which it should! It threw an error on the front-end, which is the desired outcome on the front end, so the user will enter a valid date.

  • http://nathan.lotus911.com Nathan T. Freeman

    Oh, and the other point is: Julian’s cool for writing that tool. But I thought that kinda went without saying. Emoticon

  • http://nathan.lotus911.com Nathan T. Freeman

    “And the field incidentally validated just fine with a date.”

    Put a valid date in the field. Press F9 twice.

  • http://www.runningnotes.net Kathy Brown

    Done. and Done. and done again, just for fun.

  • http://nathan.lotus911.com Nathan T. Freeman

    Well, I stand corrected. As far as I can tell, at some point @formula because tolerant of comparisons between different datatypes. This used to throw errors like “Time/Date expected: comparison operators must be of the same data type”

    I wonder when this changed. Seems like an awfully big thing to suddenly become tolerant of.

    Anyway, here’s me eating a heaping helping of crow, Kathy. You were right. Your formula is just fine.

  • Rob McDonagh

    Proof, once again, that Julian is awesome. Emoticon

  • http://jonvon.net John Vaughan

    I’d probably not go quite so far as to say ComputeWithForm is a hack. It’s a fine line I suppose, but it is an official way to do stuff, and it’s supported, etc. It’s just fraught with danger, is all. I’ve used it myself in the past, but over the years moved more and more toward script I felt I could rely on.

    Also, now that I’ve used the word “fraught” in a sentence, I think I can go home satisfied with a job well done.

  • http://www.nsftools.com Julian Robichaux

    LOL. No, YOU GUYS are awesome. You, you, and you! And you too!