mrc Documentation
michaels, ross & cole, ltd.
http://www.mrc-productivity.com/
|
|
Conditional Calculations
Conditional Calculations (Calcs) are a great tool to be able to customize your application and take them to the next level.
Some example of conditional calculation could be:
A) You are having a customer log into a page, and based on the user’s group, they will only see a hyperlink to download a certain product.
B) A user will be able to update or add or delete a record depending on the value of a field.
C) You would like to color code your data depending on its value. Whatever you are trying to do, conditional calcs add extra customizability to your applications.
How to Use Conditional Calcs
Conditional calcs take a combination of changes in your mrc application and with the painter.
For the first two examples, let’s assume we are trying to dictate what text shows depending on a value in a report. Specifically, let’s say you are working with a report that sets budgets. If the budget has not been set (currently equals 0), you want the user to click a button that lets them add the record. However, if the value does not equal 0, you want users to be able to click a button that allows them to update the budget for that line. A basic approach would be to just display both links, but with conditional calcs, we can set the application up so it is “smart” enough to know what link to display.
In the Calculations screen, we will need to add a few calculations. What we will be doing is coding both hyperlinks into the application, but with the use of <!-- & --> tags, we will comment out the hyperlink that is not applicable. To do this set up your calculations as noted below:

The rationale for setting up the calculations as noted above is that if the budget is not set to zero, we want the user to be able to update the record. Otherwise, if it is zero, the user will only be able to see the option to add the record. The “” is an mrc code that will write a space, <!-- is the beginning of a hide tag, where --> is the end of the hide tag. When we code to the painter, we will surround the different text around the appropriate calculation (mrc-Productivity Series users will need to use the substitution code of SPC_ in lieu of “”).

Note how Calc 1 and Calc 2 surround the “Update Record” text while Calc3 and Calc4 surround the “Add Record” text.
As a reminder, your link to update a record should look similar to this: LIBRARY.MXXXXXs?slnk=1&action_mode=UVK&FIELDNAME=F_V_TU[NAME]
& add mode should resemble:
LIBRARY.MXXXXXs?slnk=1&action_mode=AVK&FIELDNAME=F_V_TU[NAME]
Your final result should look like this:

Conditional Calcs & the Style of your Layout
For the final example, we will examine how to use conditional calcs to modify the style of your text based on the value of a field. To do this, we will use calculations as we did before. First, we need to decide how we are going to categorize the data. In this example, we will look at Labor Cost and divide them into three groups (0, 0 to 5, and >5). The calculations will be set up as such:

Build your application and enter the painter application. Click the source button as we will be adding some in-line style sheets. Copy this code just above the </head> tag:
<style type="text/css">
.lablow{font-family:Verdana,Arial;font-size:8pt;color:#C80000;background-color:#FFFFFF; border: 1px solid #003121;}
.labmed {font-family:Verdana,Arial;font-size:8pt;color:#003CFF;background-color:#FFFFFF; border: 1px solid #003121;}
.labhgh {font-family:Verdana,Arial;font-size:8pt;color:#FF5D00;background-color:#FFFFFF; border: 1px solid #003121;}
</style>
Feel free to edit the above code as necessary. Above, all fonts are veranda, 8pt and share a background color of white. The difference is in the text color (lablow is red, labmed is blue, and labhgh is orange).
The last step is to change the class name of your <td> tag to F_V_TN_CALCULA001 so that when the application runs it will substitute CALCULA001 for the appropriate value (lablow, labmed, labhgh) and will then apply the appropriate inline style.