If you use Cyrious for any length of time, you will inevitably be asked if you can change something in the Work Order, Estimate or Invoice layout. One of the things that separates Cyrious from almost any competitor is the extraordinary flexibility and range of options you have to make any screen or printout look the way you want it for your company. Not only can you use the layout to print whatever you capture in your pricing form, you can go much further and actually create additional calculations and formulas to control and modify what is presented. We were recently asked if we could have the Work Order show for an overnight trip how much is budgeted for the overnight stay, per diem and mileage for the Installers. This information is used to calculate the price so the task was to include it in the Work Order. The code for this shows many of the capabilities of the Layout Sheet and how to use them.

Have the Layout sheet for Work Orders only, not estimates and invoices, show the $$ and time estimated for a remote installation so the Product Supervisor can schedule and budget the installation profitably.

When working with Layout Sheets, if you make a mistake it can disable the entire sheet so that you don't see anything. The layout which controls your screen presentation is the Estimate or Summary Layout; so if you've messed up on a Detail layout, you might not know it. Usually you will get an error message that tells you something is wrong, but you can test your layout by clicking on the Detail tab at the bottom of your pricing form or Line Item. Note that you can change a Layout, Save it, and go immediately to your Work Order or Estimate to see the result. We often create a clone of the layout we are working on so that we can always go back to the one we know is right and then, when we are confident it works as it should, we change to the new one.

  1. Go to the Product for which you wish to create a revised layout. Click on the Pricing Forms/Product Layout Tab. Click on the Edit Product Layout Tab beside the Product Layout used for Work Orders. (Note that to preview or test your work, when using the Work Order layout you must select the Detail tab on your Pricing Form or your Pricing Screen). This will create a new Tab with the Layout. Clone it and then save the Cloned version. Return to the Product and in Edit Mode change the Detail layout to your new Cloned layout so you will have a test version while you work. Remember to go back and Change it to the original if you don't finish in one sitting. Note that any others users will get the “in development” version as well; so you may want to choose a time when others might not be likely to need the layout while you work.
  2. Go to your new layout and click on Edit. You will see a window very like the Formula Builder described in another page in this WIki. All the same functions and capabilties are there with the addition that the top category for the Layout is called Output Templates. This folder contains HTML code to insert in your layout so you don't even have to know anything about HTML. We have coded much of our work by copying code already written by Cyrious which we know works and then substituting new Variables and data. For the Installation module we wished to modify, the code below is what was there when we started. If you note how the format is structured, you can change the layout even though you don't have a clue what most of this stuff means.
  3. The key things you have to know when adding a new line are: It begins with HTMLLISTITEM(. It ends with the closed parenthesis and a comma: ), Any text you want to print is enclosed in quotation marks. Text and variables are combined with the plus sign. All variables which are not text must be converted to text and the Formula builder has all the functions you need for that. For example, one that we use often is DISPLAYVARIABLEVALUE(variable), E.g. DisplayVariableValue(Height), This function converts the variable height to text. Just find the function, double click on it, and it will be inserted into your formula. Before getting fancy, practice wih a test line like like HTMLLISTITEM(“Thiis is a test”);“ “This is a test” will then show up on your detail screen and you know you are on the right track.

Finally, if you want the line to print only under certain conditions, for example when a variable like Height is greater than 0, you must include the if statement. With the if statement you can work with non text variables as in any other formula. So you precede what you want to print with a statement like “IF Height > 0 THEN “Height is ” + DISPLAYVARIABLEVALUE(Height) Else _ckgedit_QUOTckgedit>ENDIF. Note that you must have the THEN and the ENDIF. The double quotes are called a null value and are the code shorthand to say the field is empty or in the case of the layout don't print anything. By adding the space after “is” you separate the number from the text by one space. Note also in the code below there is a YES/NO variable called “lift. Cyrious knows it is YES/NO so for these variables, it will return a true or false simply by using the phrase “IF lift.” You could aslo write “If lift is TRUE then “enter text here” Else _ckgedit_QUOTckgedit> ENDIF or “If lift = 1 Then “Enter text here” else _ckgedit_QUOTckgedit> Endif;

code_formatvb|code_formatvb|code format="vb" </div></html> HTMLBULLETLIST( HTMLLISTITEM( if Personnel 0 then "Installation will require a crew of " + DISPLAYVARIABLEVALUE(Personnel) else _ckgedit_QUOTckgedit> endif),

  HTMLLISTITEM(If Nights_Over  0 Then IF  IncludeOvernightInEst_Inv  Then "Price includes " + DisplayVariableValue(Nights_Over) + "  Overnight(s)"  Else "" Endif  else "" ENDIF),

  HTMLLISTITEM( if Heightaboveground  0 then  "Height is  " +  DISPLAYVARIABLEVALUE( HeightAboveGround)  +"  " +" above ground" else "" endif),

 HTMLLISTITEM( if  Ladder then "A ladder will be required" else "" endif),

   HTMLLISTITEM( if lift  then "Requires a lift" else "" endif),

HTMLLISTITEM( If TakeCement Then "Cement required in installation" Else "" Endif),

  HTMLLISTITEM( if generator   then "Requires a generator" else "" endif),

 HTMLLISTITEM( if HammerDrill  then "Requires a hammer drill" else "" endif),

 HTMLLISTITEM( if MissUtility  then "Requires OK from Miss Utility" else "" endif),

 HTMLLISTITEM( if BrickFasteners  then "Requires Brick or Masonry Fasteners" else "" endif),

  HTMLLISTITEM( if MeetClientYN  then "Meet client at site.  See comments for details" else "" endif),

  HTMLLISTITEM( if AuthorNotes  "" then "Comments on Requirements:" +  HTMLRETURN + AuthorNotes else "" endif),

 HTMLLISTITEM( if Text  "" then "Comments/Instructions" +  HTMLRETURN + Text else "" endif),

 HTMLLISTITEM( if Mileage_NoOfMiles  0 then "Miles to Install Address " +  DISPLAYVARIABLEVALUE( Mileage_NoOfMiles) else "" endif),

HTMLLISTITEM( If Install_ShipAddress  "" then "Installation Contact and Address:" +  HTMLRETURN + Install_ShipAddress + HTMLRETURN + InstallAddress else "" endif),

HTMLLISTITE

5. Next, we added our new code directly above the existing code, as shown below. For this example, you will see that we have used Cyrious' formula capabilities to create some new information while printing the Work Order. We won't go into detail here about how the code works but in the 5th line you will see that we calculate the travel expense by multiplying the variable NightsOver by the Variable OvernightRate and Personnel (number of personnel on the pricing form). The formula is designed to create the correct number when we budget 2 people to a room. These are all number variables and the calculation is returning a number; so the entire result must be converted to a string to print. Hence the entire formula is encased in the TOSTRING() function. The HTMLRETURN function tells Cyrious to add a “hard return” to the line which continues the line wihout creating a new bullet line. The two codes and tell Cyrious to begin and end underlining. This is HTML code which is not in the Formula Builder but you will find that a lot of standard HTML code will work well and you can find references for that all over the web.
code_formatvb

HTMLBULLETLIST(

  HTMLLISTITEM( if Personnel  0 then  "Estimated for "  +  DISPLAYVARIABLEVALUE(Personnel) + " Installers"else "" endif),

  HTMLLISTITEM( if Traveltime  0 then  "Estimated Travel Time:: "  +  DISPLAYVARIABLEVALUE(TravelTime) else "" endif),

  HTMLLISTITEM( if Installtime  0 then  "Estimated Time For Completion: "  +  DISPLAYVARIABLEVALUE(InstallTime) else "" endif),

    HTMLLISTITEM( if Installtime  0 then  "TOTAL Estimated Travel & Installation Time  "  +  TOSTRING(InstallTime in hours +TravelTime in hours,2) + " Hrs."else "" endif),

    HTMLLISTITEM( if nights_over  0 then "Estimated Nights Over: " +  DISPLAYVARIABLEVALUE( Nights_Over)

                   + "  @ $" + DisplayVariableValue(Overnight_Rate) +" (@ 2 person/Room) For Lodging and $" +  TOSTRING(InstallationPerDiemRate,2) + " Per Diem per person"

                   + HTMLRETURN + "TOTAL Budgeted Travel Expense (less mileage):  $"

                   + TOSTRING( (Nights_Over * OvernightRate * (Int(personnel/2) + personnel mod 2)) + (Personnel * InstallationPerDiemRate * Nights_Over)  ,2)        else "" endif),

    HTMLLISTITEM( if Mileage_NoOfMiles  0 then "Miles to Install Address " +  DISPLAYVARIABLEVALUE( Mileage_NoOfMiles) else "" endif),

HTMLRETURN+" Installation Requirements "


​​​​​​​
6. When the entire layout is combined we ended up with the following code which produced the result we were seeking;
code_formatvb

HTMLBULLETLIST(

  HTMLLISTITEM( if Personnel  0 then  "Estimated for "  +  DISPLAYVARIABLEVALUE(Personnel) + " Installers"else "" endif),

  HTMLLISTITEM( if Traveltime  0 then  "Estimated Travel Time:: "  +  DISPLAYVARIABLEVALUE(TravelTime) else "" endif),

  HTMLLISTITEM( if Installtime  0 then  "Estimated Time For Completion: "  +  DISPLAYVARIABLEVALUE(InstallTime) else "" endif),

    HTMLLISTITEM( if Installtime  0 then  "TOTAL Estimated Travel & Installation Time  "  +  TOSTRING(InstallTime in hours +TravelTime in hours,2) + " Hrs."else "" endif),

    HTMLLISTITEM( if nights_over  0 then "Estimated Nights Over: " +  DISPLAYVARIABLEVALUE( Nights_Over)

                   + "  @ $" + DisplayVariableValue(Overnight_Rate) +" (@ 2 person/Room) For Lodging and $" +  TOSTRING(InstallationPerDiemRate,2) + " Per Diem per person"

                   + HTMLRETURN + "TOTAL Budgeted Travel Expense (less mileage):  $"

                   + TOSTRING( (Nights_Over * OvernightRate * (Int(personnel/2) + personnel mod 2)) + (Personnel * InstallationPerDiemRate * Nights_Over)  ,2)        else "" endif),

    HTMLLISTITEM( if Mileage_NoOfMiles  0 then "Miles to Install Address " +  DISPLAYVARIABLEVALUE( Mileage_NoOfMiles) else "" endif),

HTMLRETURN+" Installation Requirements "

 HTMLLISTITEM( if Heightaboveground  0 then "Height is  " +  DISPLAYVARIABLEVALUE( HeightAboveGround)  +"  " +" above ground" else "" endif),

   HTMLLISTITEM( if  Ladder then "A ladder will be required" else "" endif),

     HTMLLISTITEM( if lift  then "Requires a lift" else "" endif),

   HTMLLISTITEM( if generator   then "Requires a generator" else "" endif),

   HTMLLISTITEM( if HammerDrill  then "Requires a hammer drill" else "" endif),

  HTMLLISTITEM( If TakeCement Then "Cement required in installation" Else "" Endif),

    HTMLLISTITEM( if  MissUtility  then "Requires OK from Miss Utility" else "" endif),

   HTMLLISTITEM( if BrickFasteners  then "Requires Brick or Masonry Fasteners" else "" endif),

    HTMLLISTITEM( if MeetClientYN  then "Meet client at site.  See comments for details" else "" endif),

    HTMLLISTITEM( if AuthorNotes  "" then "Comments on Requirements:" +  HTMLRETURN + AuthorNotes else "" endif),

   HTMLLISTITEM( if Text  "" then "Comments/Instructions" +  HTMLRETURN + Text else "" endif),

  HTMLLISTITEM( If Install_ShipAddress  "" then "Installation Contact and Address:" +  HTMLRETURN + Install_ShipAddress + HTMLRETURN + InstallAddress else "" endif),

  HTMLLISTITEM( If InstallAddress  "" then "Installation Contact and Address" + HTMLRETURN + InstallAddress else "" endif)

)

<code>
The result of the new code is below.
Estimated for 1 Installers

Estimated Travel Time:: 1 hr

Estimated Time For Completion: 1 hr

TOTAL Estimated Travel & Installation Time 2.00 Hrs.

Estimated Nights Over: 1 @ $100 (@ 2 person/Room) For Lodging and $30.00 Per Diem per person

TOTAL Budgeted Travel Expense (less mileage): $130.00

Miles to Install Address 125

Installation Requirements

If you have gotten this far, you have probably noticed that we assigned the company Maserati to this installation.

Contributor: Steve Gillispie, Acorn Sign Graphics Date: 07/12/2009 Version: Control 4.3

You could leave a comment if you were logged in.