Dynamic Label Names through Caption Class

ShooterShooter Member Posts: 5
Hi,

I have set up in the General Ledger Setup Table and Form 3 new text fields, Unit of Measure 1, 2, and 3. These 3 fields can be assigned a value through the General Ledger Setup Form. If left blank then the value will default as Unit of Measure 1 etc.

These 3 fields are text fields which will hold the name of the unit of measurement e.g Kilos, People, Meters, kms, miles, cow heads, etc whatever the user specifys in the General Ledger Setup Form.

Labels from other forms and the actual fields which are replicated throughout the database as Unit of Measurement 1 but type decimal, will have there caption set as whatever was specified in the General Ledger Setup Form. I have tried doing this through the Caption Class property on the unit of measurement labels and fields linking to the unit of measurement text field in the General Ledger Setup table however have not got it to work (getting empty). Does anyone know how to get this to work through caption class or perhaps has another way of achieving what i want to do?

Comments

  • krzychub83krzychub83 Member Posts: 120
    edited 2008-04-11
    Hi Shooter
    I was trying to solve Your problem on my break at work. I realized that there isn't a good solution for You (depending on my knowledge).

    Unfortunately You can't change names of labels. My solution is to use TextBoxs instead:
    OBJECT Form 50100 Test1
    {
      OBJECT-PROPERTIES
      {
        Date=08-04-11;
        Time=08:53:33;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=6490;
        Height=880;
      }
      CONTROLS
      {
        { 1000000000;CommandButton;3960;110;2200;550;CaptionML=PLK=SetName;
                                                     OnPush=BEGIN
                                                              Form1.setname(TextToSet);
                                                              Form1.RUN;
                                                            END;
                                                             }
        { 1000000001;TextBox;110  ;220  ;3520 ;440  ;SourceExpr=TextToSet }
      }
      CODE
      {
        VAR
          Form1@1000000000 : Form 50101;
          TextToSet@1000000001 : Text[30];
    
        BEGIN
        END.
      }
    }
    
    OBJECT Form 50101 Test2
    {
      OBJECT-PROPERTIES
      {
        Date=08-04-11;
        Time=08:55:58;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=5500;
        Height=880;
        CaptionBar=Narrow;
        ActiveControlOnOpen=1000000001;
        SourceTable=Table5200;
        OnOpenForm=BEGIN
                       //CurrForm.NAME1.CAPTION():=MYNAME;
                   END;
    
      }
      CONTROLS
      {
        { 1000000001;TextBox;3520 ;220  ;1700 ;440  ;Name=NAME1;
                                                     SourceExpr="No.";
                                                     TableRelation=Employee }
        { 1000000004;TextBox;110  ;220  ;3300 ;440  ;Enabled=Yes;
                                                     Editable=No;
                                                     Border=No;
                                                     SourceExpr=myname }
      }
      CODE
      {
        VAR
          myname@1000000000 : Text[30];
    
        PROCEDURE setname@1000000000(text1@1000000000 : Text[30]);
        BEGIN
          myname := text1;
        END;
    
        BEGIN
        END.
      }
    }
    


    Try to move on in my solution. OnOpenForm: Get the active name from General Ledger Setup Table, and save it into local variable(, with is a SourceExpr of a TextBox).

    Textbox:
    - Border: None
    - Editable: No
    - SourceExpr: LocalVariable

    Meybe later I'll be able to help You better... I hope it will help You...
  • DaveTDaveT Member Posts: 1,039
    Hi Shooter,

    You can set the captions on the fly look at post

    http://www.mibuso.com/forum/viewtopic.php?t=6746

    I tried '1,5,,'+... on version 5.0 and its does work. The later post of '3,'+... works fine. Make sure you set in the captionclass property of the field and not the caption. Set the variable in the oninit trigger

    Hope this helps
    Dave Treanor

    Dynamics Nav Add-ons
    http://www.simplydynamics.ie/Addons.html
  • ShooterShooter Member Posts: 5
    Hi,

    Thanks for the replies, this is what I did in the end (does not work on tables):

    Create 3 global variables

    txtMyCaption1
    txtMyCaption2
    txtMyCaption3

    C/AL - Code on Form

    Form - OnInit()

    // FDEV-1002 GRP 090408 COD 01b

    GLSetup.GET('');
    IF GLSetup."Unit Of Measure Quantity 1" = '' THEN
    txtMyCaption1 := FIELDCAPTION("Unit Of Measure Quantity 1")
    ELSE
    txtMyCaption1 := GLSetup."Unit Of Measure Quantity 1";

    IF GLSetup."Unit Of Measure Quantity 2" = '' THEN
    txtMyCaption2 := FIELDCAPTION("Unit Of Measure Quantity 2")
    ELSE
    txtMyCaption2 := GLSetup."Unit Of Measure Quantity 2";

    IF GLSetup."Unit Of Measure Quantity 3" = '' THEN
    txtMyCaption3 := FIELDCAPTION("Unit Of Measure Quantity 3")
    ELSE
    txtMyCaption3 := GLSetup."Unit Of Measure Quantity 3";

    // FDEV-1002 GRP 090408 COD 01e

    Form - OnOpenForm()

    // FDEV-1002 GRP 090408 COD 02b

    IF (txtMyCaption3 = '') OR (txtMyCaption3 = 'Unit Of Measure Quantity 3') THEN
    CurrForm.UOM3.VISIBLE(FALSE) ELSE
    CurrForm.UOM3.VISIBLE(TRUE);

    // FDEV-1002 GRP 090408 COD 02e

    Properties on Field (field that you want to have a dynamic caption for)

    CaptionClass:
    '3,' + txtMyCaption1

    Other Notes:

    The caption name is set in the General Ledger Setup Form and is simply a text field that can be entered into through a text box on the form.
Sign In or Register to comment.