Transformation Tool : FontBold on Controls


FontBold property sets a value that indicates whether to display text in boldface. This property applies to form controls. In standard application this property is normally used to display accounts that are not posting accounts in boldface (form16 - Chart of Accounts). 

For a page field control, Style Property is used to format the text that displays in a page field. More details about this can be found in Microsoft Dynamics NAV Developer and IT Pro Documentation, designing pages.

When running Transofrmation Tool to transform forms to pages in NAV 2009 SP1, records displayed in boldface on a form are not displayed in boldface on the page, after the transformation.

To change this, following files should be modified:

Page.xsd (add property definition to page field control):

      ....

      <xs:element name="ClosingDates" type="NavBoolType" minOccurs="0" maxOccurs="1" />
      <xs:element name="Numeric" type="NavBoolType" minOccurs="0" maxOccurs="1" />
      <xs:element name="DateFormula" type="NavBoolType" minOccurs="0" maxOccurs="1" />
      <xs:element name="Style" minOccurs="0" maxOccurs="1">  <!--  This is where the Style property is added. BEGIN changes  !-->
      <xs:simpleType>
          <xs:restriction base="xs:string">
              <xs:enumeration value="None" />
              <xs:enumeration value="Strong" />
              <xs:enumeration value="Attention" />
              <xs:enumeration value="Favorable" />
              <xs:enumeration value="Unfavorable" />
          </xs:restriction>
      </xs:simpleType>
   </xs:element>
   <xs:element name="StyleExpr" type="xs:string" minOccurs="0" maxOccurs="1" />   <!--  This is where the StyleExpr property is added. END changes  !-->
</xs:all>
</xs:complexType>
....

Now that we have added Style and StyleExpr properties to the field control in page definition, we must modify CodeRules.txt file to transfer UPDATEFONTBOLD function to <FieldName>Emphasize variable defined for each field on page (that UPDATEFONTBOLD function was called for on a form).

In addition, Style property of the field shuld be set to Strong, and StyleExpr property to <FieldName>Emphasize. Transformation tool already creates a trigger called <FieldName>OnFormat for each field affected, that sets the value of <FieldName>Emphasize variable conditionally.

In short, replace the following code in file CodeRules.txt:

.....

 <find>
!currForm!.!var1!.UPDATEFONTBOLD :=
<declareVariable>
!var1!Emphasize
<declareVariableType>
Boolean INDATASET
<replace>
!declaredVariable! :=
<comment>

.....

with

<find>
!currForm!.!var1!.UPDATEFONTBOLD :=
<replace>
!currForm!.!var1!.UPDATEFONTBOLD :=
<moveValueToProperty>
Strong
<movePropertyToControlName>
!var1!
<moveToProperty>
Style

<find>
!currForm!.!var1!.UPDATEFONTBOLD :=
<declareVariable>
!var1!Emphasize
<declareVariableType>
Boolean INDATASET
<replace>
!declaredVariable! :=
<moveValueToProperty>
!declaredVariable!
<movePropertyToControlName>
!var1!
<moveToProperty>
StyleExpr

Run transformation tool on from 16, import and compile the page. When running page 16 (Chart of Accounts) the records should be displayed in boldface, the same way they are displayed on the form.

Jasminka Vukovic 

Microsoft Dynamics NO

Microsoft Customer Service and Support (CSS) EMEA

These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.

 

 

TTool extended.zip

Comments (5)

  1. dsteiner says:

    Hello Jasminka

    This is really a good extension of the form transformation.

    Unfortunately it doesn’t work well with the Swiss Release (e.g. field ‘Description’ on  ‘Sales Quote Subform’). In that page it makes all lines bold.

  2. dsteiner says:

    Great idea!

    Your extension needs code changes in some forms, e.g. 5052. Otherwise "all" contacts are bold.

  3. MSDN Archive says:

    Thanks for your feedback! It seems this needs further improvement. For std form 5052 – Contacts – conditional formatting for fields name and no. need to be included in coderules.txt, as describing how to make changes wiht copy/paste/replace becomes to cumbersone at this point, coderuls.txt file is attached. Contact form should be transformed properly now. As for swiss localized form, I will get back to it next week.

  4. dsteiner says:

    Combining bold with other options has "strange" effects. Example object:

    OBJECT Form 50000 DaSt Test

    {

     OBJECT-PROPERTIES

     {

       Date=24.12.09;

       Time=09:16:54;

       Version List=DaStXXX;

     }

     PROPERTIES

     {

       Width=10010;

       Height=8000;

       SourceTable=Table5050;

     }

     CONTROLS

     {

       { 1161020000;TextBox;1540 ;660  ;2750 ;440  ;SourceExpr="No." }

       { 1161020001;Label  ;990  ;660  ;990  ;440  ;ParentControl=1161020000 }

       { 1161020002;TextBox;1540 ;1210 ;5500 ;440  ;SourceExpr=Name;

                                                    OnFormat=BEGIN

                                                               IF Type = Type::Company THEN

                                                                 CurrForm.Name.UPDATEFORECOLOR(255)

                                                               ELSE

                                                                 CurrForm.Name.UPDATEFORECOLOR(0);

                                                               CurrForm.Name.UPDATEFONTBOLD(Type = Type::Company);

                                                             END;

                                                              }

       { 1161020003;Label  ;990  ;1210 ;1760 ;440  ;ParentControl=1161020002 }

       { 1161020004;TextBox;1540 ;1760 ;5500 ;440  ;SourceExpr=Address;

                                                    OnFormat=BEGIN

                                                               IF Type = Type::Company THEN

                                                                 CurrForm.Address.UPDATEFORECOLOR(255)

                                                               ELSE

                                                                 CurrForm.Address.UPDATEFORECOLOR(0);

                                                             END;

                                                              }

       { 1161020005;Label  ;990  ;1760 ;1760 ;440  ;ParentControl=1161020004 }

       { 1161020006;TextBox;1540 ;2310 ;5500 ;440  ;SourceExpr=City;

                                                    OnFormat=BEGIN

                                                               IF Type = Type::Company THEN

                                                                 CurrForm.City.UPDATEFORECOLOR(65280)

                                                               ELSE

                                                                 CurrForm.City.UPDATEFORECOLOR(0);

                                                               CurrForm.City.UPDATEFONTBOLD(Type = Type::Company);

                                                             END;

                                                              }

       { 1161020007;Label  ;990  ;2310 ;1870 ;440  ;ParentControl=1161020006 }

       { 1161020008;TextBox;1540 ;2860 ;2750 ;440  ;SourceExpr="Territory Code";

                                                    OnFormat=BEGIN

                                                               CurrForm."Territory Code".UPDATEFONTBOLD(Type = Type::Company);

                                                             END;

                                                              }

       { 1161020009;Label  ;990  ;2860 ;1760 ;440  ;ParentControl=1161020008 }

     }

     CODE

     {

       BEGIN

       END.

     }

    }

  5. MSDN Archive says:

    I’ve tested this form, and it actually works just as it should. The thing is, we had number of font properties to control layout on forms. On pages there is style, and that is pretty much it. Now you can still change colors and choose font bold, but only to some extent. These are your options now:

    Value     Format in Edit mode   Format in View

    ************************************************

    Strong            Bold            Bold

    Attention         Red             Default

    Favorable         Bold + Green    Bold

    Unfavorable  Bold + Italic + Red   Bold + Italic

    and what the output will look like is now determined with style option value. My code example was aimed at transforming forms to pages and preserving bold font option. And in your example, fonts that are bold on form are also bold on transformed page. But if you want to also transfer the colors, then style option value used should be changed. This requires a bit more fiddling as the different values of color code parameter must be matched to style options, but is something worth considering. Let me have a look at this and I will try to post an example of ‘best effort’ transformation of these colors as well (to the extend it’s possible automatizing).

    Regards,

    Jasminka

Skip to main content