Skip to main content

Calculations - Knowledgebase / Lasernet / Lasernet Training / Lasernet Form Editor 9 - Designing Forms - Formpipe Support Portal

Calculations

Authors list


With the Calculation tool, you can insert calculations in the Conditional Area. In this exercise, we are going to make a focus on subtotals and sum of all item lines.

Sum: Generates a rearrange script  in the output calculating the sum of all values of the Conditional Rearrange. The rearrange is inserted after the Conditional Area enabled for the current page type.

Subtotal Current Page: Generates a rearrange script in the output calculating the sum of all values of the Conditional Rearrange on all pages up to and including the current page. The rearrange is inserted after the Conditional Area enabled for the current page type.

Subtotal Previous Page: Generates a rearrange script in the output calculating the sum of all values of the Conditional Rearrange on all pages up to and excluding the current page. The rearrange is inserted before the Conditional Area enabled for the current page type.

Exercise

Download and import the attached configuration called 18. Calculations in Lasernet Developer 9. Afterwards, go to the Forms section and open the Sample form.

1. In the output, switch to the Last Page tab.

2. Select the first pattern rearrange of the Amount column and edit its Formats properties.

3. Select Amount in the Objects list.

4. Select Number as Format category.

5. Once you are done, click Ok.

6. Repeat the same steps to edit the Formats properties for the last pattern rearrange in the Amount column.


7. Use the the Text tool, to add a fixed text to the footer of the form. Open the Edit Rearrange dialog to edit the fixed text object properties.

8. Switch to the Formats tab and set Format category to Number.

9. Switch to the Objects tab and set Object type to Script.

10. Type Sum(Amount); in the script field.

11. Once you are done, click Ok.

12. In the output, select the rearrange specified as [script] you have just added.

13. Set Font Size to 18 pt.

14. Set the X position to 196 mm and Y to 280 mm.

15. Set Font style to Bold.

16. Align the object right.

17. Select the object, right-click it, and then set the Absolute position to Last and Single.

18. To view the result of the calculation for the Amount column, press Shift+F5. Otherwise, on the Menu bar click View, and then click Run JavaScript.

Following the steps above, you have added the sum to the Amount column at the bottom of the last and single pages by manually setting the parameters. Besides, you can use the Calculation tool to automatically add such parameters as object names and number formatting to the selected rearranges.

Now proceed with the steps listed below to add subtotals.

19. In the output, switch to the First Page tab.

20. Select the Amount rearrange.

21. On the toolbar, click Calculation and select Subtotal CurrentPage.

Change the End Y position to 275 mm on the First Page and the Middle Page. The [script] calculation is now positioned inside the box.

The SumSubtotal(Amount) system script used to calculate the subtotals for the Amount column on the First Page is added with a unique Object name to the bottom of the Conditional Area. The Format category property is set to Number.

The Calculation tool has added the required parameters to the Objects settings. The Relative to property of the subtotal is set to Bottom of the Conditional Area with an Y-pos set to 4.5 mm (default value).

11_position-tab.png

In addition, set the following properties of the subtotal:

22. Specify 5.5 mm for the Y position.

23. Set the Absolute position to First and Middle.

24. Once you are done, click Ok.

25. Afterwards, set the Font style to Bold.


26. Add a new fixed text rearrange, change its label to Transfer to next page. Afterwards, set the Font style to Bold.

27. Edit the position properties of the rearrange by setting Relative to to Bottom of cond. area(Absolute).

28. Set Absolute position for First and Middle pages by selecting the corresponding check boxes.

29. Set the X position to 42 mm.

30. Set the Y position to 5.5 mm.

31. Once you are done, click Ok.

32. In the output, switch to the Middle Page tab.

33. Select a rearrange in the Amount column.

34. On the Developer toolbar, click Calculation, and then click Subtotal PreviousPage.

The SumSubtotal(PreviousPage, Amount) system script used for calculating subtotals for the previous page is added to the top of the Conditional Area.

35. Set the Start Y position on the Middle and Last pages to 115 mm. To this end, drag the dotted line to the required position.


36. On the Position tab, set the Y position to -3 mm.

37. Set the Absolute subtotal position for the Middle and Last pages by selecting the corresponding check boxes.

38. Once you are done, click Ok.

39. Afterwards, use the Property bar to set the Font style to Bold.

40. Add the Transfer from previous page fixed text object.

41. Edit the object properties by setting Relative to to Top of cond. area.

42. Then set the Absolute position for the Middle and Last pages.

43. Afterwards, use the Property bar to set the Font style to Bold, the X position to 42 mm and Y to -3 mm.

Validate calculated sums by clicking View on the Menu bar, and then clicking Run JavaScript, or press Shift +F5.

19_run-java-script.png


44. On the Menu bar, click Sheet, and then click Sheet Options. Switch to the Format tab.

45. Select the Default profile and click the Edit button to replace the current profile with a another one.

46. In the Edit Regional Profile Mapping dialog, click Add... to add a new regional profile

47. Type a name (US) of a new regional profile.

48. Click the Import button.

49. In the dialog box displayed, select English (United States) as the default regional profile.

50. Click Ok to import the regional profile.

51. Afterwards, click Ok on every dialog to include in the regional profile to the list.

52. On the Sheet Options dialog, click Ok to accept the regional profile you have just added.

Decimal and digit grouping have changed to a new regional format for the rearranges which have Format category set to Number. You can also apply a definite regional profile to a specific rearrange which overrules the general settings defined for this particular sheet.


53. Select rearranges in the Quantity column to edit their properties. Open the Edit Rearrange dialog and switch to the Formats tab.

54. Set Number as Format category.

55. Switch to the Output format tab and select the Override sheet output format check box.

56. Select the regional profile in the list, click to replace it with the US regional profile.

57. Set 0 as a Number of decimals value.

58. Click Ok to accept changes.


You have now managed to change the number format for a specific rearrange.




Helpful Unhelpful

Add a comment

Please log in or register to submit a comment.

Need a password reminder?

Share