Updates from Ken Sobieski Toggle Comment Threads | Keyboard Shortcuts

  • Ken Sobieski 2:05 pm on December 12, 2011 Permalink | Reply
    Tags:   

    LotusScript for the VB Developer 

    So, you’re a VB developer and you need to modify a Notes app without much Notes knowledge? Hopefully you are not just a .Net programmer and have either some experience with VBScript because that will help quite a bit with LotusScript. If so, here are a few tidbits that may lessen your pain as you dig into the code…

      1. Notes is extremely flexible! (Maybe too flexible?)
        If you come from a structured data background, Notes can be a bit disconcerting. Notes documents are designed to mimic a real-world document; you may have a pre-defined structure but, if necessary, you can mark in some other information. If you run across a field in a script that you can’t seem to locate no matter how hard you look, it is quote possible that the field and data were created on-the-fly. Check your document events and shared scripts; chances are you’ll eventually find what you are looking for.
      2. Beware the variables
        If you work in an environment that demands explicit declaration of variables, you may find areas where implicit variable types exist. In Notes, Option Declare (or Option Explicit) must be speified to enforce explicit declarations. Without, you may find a script peppered with Variant types that “just show up.” (And, just in case, LotusScript is not case-sensitive.)
        LotusScript will also let you declare multiple variables on a single line, each with a different (or no) datatype. If you run across a scenario where the data type appears not to be defined, there may be two possibilities:

        1. The variable is implicitly cast as a Variant (Object) type or,
        2. The variable may be cast using shorthand declaration (e.g., aString$, anInt%, etc.):
          Keyword Suffix Data Type Range
          Integer % Integer -32,768 to 32,767
          Long & Integer -2,147483,648 to 2,147483,647
          Single ! Floating-point -3.402823E38 to 3.402823E38
          Double # Floating-point -1.7976931348623158E308 to 1.7976931348623158E308
          Currency @ Currency -922,337,203,685,477.5808 internal format to 922,337,203,685,477.5807
          String $ String ~16k characters
          Variant NONE Can contain any of the preceding, plus Date/Time, Boolean,and objects
    1. LotusNotes documents and mail are tightly integrated
      Need to send an email? There is no “special” e-mail function in Notes because it is inherent in the design. Simply tack a “To” and “From” to a document (at a minimum), invoke “Send” and, voila, you’ve sent an e-mail (assuming your mail is configured correctly). OK, maybe it’s not just that easy, but pretty close so, if you see a document with this going on, it’s becoming mail.
    2. A lot of (if not all) fields have indices
      When is a checkbox not a checkbox? When it’s in Notes! Don’t expect to find a “checked” property available to your script. Instead, a checkbox may have multiple values set and, if checked, you will need to check the value of the control. If multiple options are selected, they will be accessible by index (e.g., if a checkbox “LightColors” has options “Red”, “Yellow”, and “Green”, and each is selected, LightColors(0) will be “Red”, LightColors(1) will be “Yellow, etc.) if NO options are selected, index 0 will evaluate to an empty string (“”).
      Textboxes, too, may have indices. Index 0 will return the text in the box. If the textbox is multi-line, the indices will refer to each line, as defined by the delimiter (space, new line, comma, semi-colon or a blank line).

    More to come…

     
  • Ken Sobieski 11:23 am on November 28, 2011 Permalink | Reply
    Tags:   

    JavaScript and the CRM 2011 DateTime Field: Deconstructed 

    Suffice it to say, the DateTime control is not very intuitive when you need to manipulate pieces of it so, if you found your way here you are probably climbing the walls trying to figure out how to manipulate it.

    A project I am working on has a requirement where I simply needed to disable the date part of the field. After much searching, I wasn’t really getting where I needed to be until I paired the little information I had with the  which lead me to explore (and document) my findings to help someone else wrestling with this.

    If we look at the code snippet below which defines the control in the page (in this case we are looking at an appointment’s “scheduledstart”), we can see that it is quite complex in the structure (the left of the snippet documents the childnode indices of the control). However, by using the DOM, we can achive just about anything we would like.   To access each of the elements, of the control, you traverse the DOM tree using javascript .childnodes property.

    //The date textfield of the control
    document.getElementById(“scheduledstart”).childnodes[1].childnodes[0].childnodes[0].childnodes[0]

    //The date imgbutton of the control (opens the date selector)
    //NOTE: if you are disabling this control, set the image to ‘_imgs/btn_dis_cal.gif’, the “greyed-out” control
    document.getElementById(“scheduledstart”).childnodes[1].childnodes[0].childnodes[1].childnodes[0]

    //This can also be accessed by  crmForm.all.scheduledstartimg
    // as I understand it, related imagebuttons will always be named “<related control name>img”

    While the time selector part of the control appears to be a standard SELECT control, it is, in fact, a text box paired with an image button. To disable the control, the easiest route is just to disable the TD that the control lives in:

    //The time selector of the control
    document.getElementById(“scheduledstart”).childnodes[1].childnodes[0].childnodes[2]

    If you need finer-grained control and want the parts, while I have not tested this, the indices should be:

    //time text box
    document.getElementById(“scheduledstart”).childnodes[1].childnodes[0].childnodes[2].childnodes[0].childnodes[1].childnodes[0].childnodes[1].childnodes[0].childnodes[0].childnodes[0]

    //time image button
    document.getElementById(“scheduledstart”).childnodes[1].childnodes[0].childnodes[2].childnodes[0].childnodes[1].childnodes[0].childnodes[1].childnodes[0].childnodes[1].childnodes[0]

    Happy coding!

    DateTime Control Snippet

     
  • Ken Sobieski 1:54 pm on November 18, 2011 Permalink | Reply
    Tags: MS SSRS   

    Outlook Mail Attachment’s from SSRS 

    It would be naïve to think that The World Wide Web is by any means a “safe” place to be. If I were developing a browser, I would likely do everything I could to protect the public from the outlaws in the Ether.  That being said, there are, on occasion, legitimate reasons to want to perform actions on an Intranet that should never be allowed in the wild.

    Recently I was exploring attaching a file created from SQL Server Reporting Services (SSRS), running on an intranet web app, directly to a MS Outlook Email. Using the Outlook ActiveX from JavaScript makes it relatively painless to open up an Outlook E-mail, set the information and attach a file. Using SSRS, the best approach to tackling the attachment seemed to be either stream the file directly into an Outlook attachment or download the file directly (read: without prompts)  to the client and attaching the file.

    For those not familiar with SSRS, it has some great features for creating reports and easily exporting them (to PDF, Excel, etc.). There are even alternate ways to access reports in multiple formats, including:

    1. Using the SSRS viewer control, the user has buttons to export as they see fit
    2. In code, one can use the viewer to export or save a report programmatically
    3. Direct via  URL/Parameters

    There had to be a way, given the flexibility of the service, to solve this problem. The answer: “Sort of.”

    I began using a VS2008 report viewer control. This route allowed me to use server-side code to generate the report to a PDF and save it to the client, but this required the user to acknowledge the file download. I then looked at the web services to stream the file directly to a byte array and send it to the client. Almost, but not quite – the user still needs to acknowledge the file download. I tried to use the server control itself to generate a file, but this was saved on the server-side (as expected), and not directly accessible to the client. I also tried WinHTTP to grab the file and save it using FSO but that wasn’t built for binary files, and the ADODB.Stream Object is disabled for access without a registry hack that could cause even larger issues (not to mention not being an easy thing to do on machines in a client’s network).

    A little more digging gave me hope when I learned the report viewer in VS2010 had a JavaScript API. This HAD to be the solution! There is, in fact, an ExportReport method but again, the user is prompted to accept the report. Not what I had hoped for.

    My final attempt lead me to consider Acrobat automation. While the ActiveX API has many functions, I was again faced with an inability to take a stream and save it to the client without intervention. Strike 100…

    If you found your way to this post because you have a similar requirement, hopefully my journey will save you some time exploring these paths. I did come up with a sort-of-work-around thanks to input from the guys around me (sometimes you can get so focused on the tree you forget there’s a forest, too). Assuming your requirement is for an Intranet app, and the users with the requirement and the servers are on the network, you can save the file server-side to a shared network location and attach it from the share. This save the user from a having to intervene and gives them a nice Outlook e-mail with the report attached. As with a lot of solutions, it’s not pretty, but it works…

    It’s good to know that not just anyone can download a file to a (read: my) machine without explicit permission but, in this case, there needs to be a way to allow files to be downloaded without notification as long as it has been set as a trusted site. Lock it down as a general rule, but let me decide if I want to (potentially) shoot myself in the foot. With web apps quickly replacing traditional desktop apps, there needs to be a way to set the browser’s security settings lower to enable more full-featured functionality.  I don’t want to have to write a browser plug-in every time I need to do something out of the norm.

     
  • Ken Sobieski 10:41 am on November 2, 2011 Permalink | Reply
    Tags:   

    Things I have learned about CRM so far 

    Things I am having to learn, or have learned, about CRM:

    • Individual fields are set “dirty” rather than the entire record, reducing the chance of a collision (if you want to know more, look here)
    • The back-end data structure (e.g., where things like user time zone information live — can you say “user settings“)
    • Creating new fields (hey, the “whole number” type can be formatted to display as a time zone list!)
    • Processes & Work Flows
    • and, of course, all the other pieces to build “the right solution” for the customer (thanks to the Channel 9 crew for a ton of good information!)

    I’ll keep posting (hopefully) good information as I learn to leverage the power of Dynamics CRM as well as other CRM and data packages. If I’m lucky, maybe along the way I’ll find better and easier ways to accomplish my tasks and, if not, at least you may benefit from my pain conquering a problem “the hard way.”

    Oh, and if you are listening, Microsoft, would it be that unreasonable to ask for a package like this to make manipulating the UI a little less cumbersome? I mean, really, you already have such a nice AJAX tool set…just saying.

     
  • Ken Sobieski 11:30 am on October 26, 2011 Permalink | Reply  

    Off the deep end… 

    I was born a poor…well, you know how that goes. Suffice it to say that the most-important part of my story for our purposes is the last week of my life, beginning work with Traction Consulting Group.

    As a VB/ASP.NET programmer with roots in Microsoft Access and SQL Server databases, I thought that jumping into CRM would be a snap. I mean, really, a cursory review looks similar Access (at least as far as dragging and dropping fields) and, being a Microsoft product, I was expecting some form of code-behind files with, maybe, a bin for modules and  custom classes. I assumed I could throw some .NET code at it to “make it work” — well, maybe not so much.

    So where am I after five days?

    Things that I’ve had to revisit and remember:

    • JavaScript and its idiosyncrasies (how do I live without strong data typing reference parameters??)
    • SOAP calls to query the backend in the online version (I know this can now be done with oData or WCF, but that’s for future exploration and most-likely a blog entry or 50)
     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel
%d bloggers like this: