Clarity Service Management

Expand all | Collapse all

Calculated Column in a list form?  (12.6)

Jump to Best Answer
  • 1.  Calculated Column in a list form?  (12.6)

    Posted 08-26-2013 06:06 PM
    [size=6]What I'd like to do is add a calculated column on a list form. The displayed content will be derived from the a field's value but won't actually be in it's own table anywhere. The idea is something like this...

    field x in table y could have any of the following values in it...
    [list]
    [*]'Mickey Mouse'
    [*]'Donald Duck'
    [*]'Pluto'
    [list]
    When I'm on the list form for table y I don't want to actually display the character's name. I want to display alternate text but that text isn't in the DB anywhere. The scenarios are limited enough that I can get away with it at the form level. I did this easily in 11.2 but at the time it wasn't using embedded list forms. It was building the html raw within a pdm_list statement. I could add my own variables, parse the data and then with a case statement spit back the appropriate text I wanted in a <td> tag. In 12.6 I have to work with the lscol/lswrite tags and I'm not sure how to pull this off since it looks like lscol has to take a database attribute and I don't want to do that. Use the below as the sample logic.

    if(x = 'Mickey Mouse') Display 'Easily Understood'
    else if(x = 'Donald Duck') Display 'Hard to Understand'
    else if(x = 'Pluto') Display 'Doesn't speak at all'
    else Display 'Speech Quality Unknown'

    How would I make this work?[size]


  • 2.  RE: Calculated Column in a list form?  (12.6)

    Posted 08-26-2013 09:55 PM

    brettzipkin4202453 wrote:

    . . . The displayed content will be derived from the a field's value but won't actually be in it's own table anywhere.
    Hello brettzipkin4202453,

    Playing Devil's Advocate here, and I know you're after the technical way to do what you've asked (Which it would be good if someone could comment on) but:

    Why not add a small table?
    There are plenty of small tables, and they allow you to have different columns with different display options for Symbol or Code or Name. See "Priority" Table for example which is only a handful of rows.

    It's the straight forward way of doing it, easy by Web Screen Painter, requires no hand customisation of forms, is easier to upgrade and maintain . . .

    Kyle_R.


  • 3.  RE: Calculated Column in a list form?  (12.6)

    Posted 08-27-2013 10:06 AM
    [size=6]Because I oversimplified the scenario for the purpose of an answer. The values I'll be parsing are only part of a string in a field. I'm actually only going to be looking at few characters of a text string. In the end I'm going to be stripping a few characters off the beginning of a string and if they match a predetermined pattern displaying one a few items. There is no dedicated field for the data points I'm using and I have a relatively complex customization already in place based on it that I really don't want to have to re-write for a new solution. If I can make this work, it'll be much easier for me.[size]


  • 4.  RE: Calculated Column in a list form?  (12.6)
    Best Answer

    Posted 08-27-2013 12:09 PM
    [size=5]Ah HA! I figured it out....


    Here's a snipit of the logic in case anyone is curious... Basically, I used lsWrite to create some local variables parsing what I wanted. Then I wrote a custom function to use for the fmtfunc attribute of an lscol which reset the data value based on my own logic.
    [size]
    [size=6]function sample_display(value)
    {
    
    switch(field_type)
    
    {
          case "100002":
    
    
    value = "CHECKBOX";
    
    
    break;
          case "100003":
    
    
    value = "DROP DOWN";
    
    
    break;
          case "RDO":
    
    
    value = "READ ONLY";
    
    
    break;
    
    .
    
    .
    
    .
          default:
    
    
    value = 'FREE FORM'
    
    }
       rs.data(value);   
    }
    
    
    var field_type = ''
    
    <PDM_MACRO name=lsWrite text="var val_type = \"@{list.validation_rule.validation_type:}\";">
    <PDM_MACRO name=lsWrite text="var my_samp = \"@{list.sample:}\";">
    <PDM_MACRO name=lsWrite text="if (val_type == \"\" || val_type == null) field_type = my_samp.substring(0,3); else field_type = val_type;">
    
    <PDM_MACRO name=lsCol hdr="Field Type" attr=sample fmtfunc=sample_display sort=no startrow="no">
    [/size]


  • 5.  RE: Calculated Column in a list form?  (12.6)

    Posted 09-18-2013 04:04 AM

    brett_zipkin wrote:

    [size=5]Ah HA! I figured it out....

    Here's a snipit of the logic in case anyone is curious... Basically, I used lsWrite to create some local variables parsing what I wanted. Then I wrote a custom function to use for the fmtfunc attribute of an lscol which reset the data value based on my own logic.
    .
    .
    .
    Brilliant!

    Thanks for letting us know. I'm sure that someone will search and find this later. Every bit of knowledge helps.

    Kyle_R.