Wednesday 26 July 2023

Dynamic fonts in SSRS reports

 Sometimes we need to set the Font style and size on the SSRS reports based on the user needs. This can be achieved using the dynamic expressions available in SSRS report properties. Below is a similar scenario with an example.

Let us take a simple report which print the two fields. One is warehouses and the other is location. Now the font size of the each field should be printed according to the user input. Below is the sample design and code for the scenario.


1. Create the controller, and services classes as required.

2. In the contract class add integer fields as parameters to get the font size as input from user as below.




3. Now in the SSRS report design select the properties of the textbox for which this font size needs to be applied.

4. Click on the Font tab and select the fx expression button for font size as below.


5. Now under category section click on the parameter. The list of parameters available in the report will be displayed. Select the parameter which we created for font size in the contract class.


6. Actual font size will be of string value. Ex, '10pt'. But since the parameter we specified is of integer type, if we use the parameter value directly then the font size wont be applied. It takes the default font size.

7. In order to convert it to string and use use it change the expression as in below image.



8. Now Save, build and deploy the report. The report should bring the fonts based on the user input.







Tuesday 18 July 2023

Move AOT elements between models

In order to move the objects from one model to another model, we opt to copy -paste from original model`s physical folder to destination model`s folder. This is feasible when we have limited objects. but if the object count is more, this approach is tedious.
So here is another way to move the objects from one model to another.
  1. Open the project which has all the objects.
  2. In the same solution, create another project and set its model to the new one .
  3. Drag and drop the objects from the above project to the new one .
  4. Sync and Rebuild.
  5. Now the objects are ready in new model .
This way our job becomes easy and we can be sure the objects are not missed because there are chances of missing the objects when they are moved across physical locations.