Customized captions at run-time without changing Codeunit 1

kriki
Member, Moderator Posts: 9,121
If you want to use customized captions on a field, mostly you change Codeunit 1 to do it. I found a way to use customized captions without changing Codeunit 1.
In the CaptionClass Property you have to put '1,5,,' + txtMyCaption. Or you can also put a function that returns the string.
Some explanation:
The first parameter says it is a dimension
The second parameter says to use a certain format (= optional parameter 1 + dimension caption + optional parameter 2) of the dimension-code (not value-code!) put in parameter 3.
The third parameter is the dimension-code you want. This parameter must contain a value that does not exist in the dimensions (a blank for example). If this dimension does not exists, codeunit 1 shows the fourth parameter on the caption.
The fourth parameter : the value you want to show as caption.
In the CaptionClass Property you have to put '1,5,,' + txtMyCaption. Or you can also put a function that returns the string.
Some explanation:
The first parameter says it is a dimension
The second parameter says to use a certain format (= optional parameter 1 + dimension caption + optional parameter 2) of the dimension-code (not value-code!) put in parameter 3.
The third parameter is the dimension-code you want. This parameter must contain a value that does not exist in the dimensions (a blank for example). If this dimension does not exists, codeunit 1 shows the fourth parameter on the caption.
The fourth parameter : the value you want to show as caption.
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
0
Comments
-
-
In the properties of the table I can only work with static values like:
'3,new caption'
and ctrl-f8 worked.
In the form it was more variable.
In the data properties of a field set it to '3,' + txtMyCaption
In the OnInit of the form do:
txtMyCaption := 'New caption';
and ctrl-f8 still uses the old caption, but for me this was good enough, thx0 -
-
lyot wrote:Doesn't work for me at all :?
Nav 5.0. SP1Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
If I modify this in the CaptionClass property of the field on the form, nothing changes...
If I modify this in the CaptionClass property of the field on the table...
then I have even stranger things...
A first look shows me that nothing changed... but when I do a Zoom on the form (CTRL+F8 ) and I choose to show columns field & fieldname.
Field is blank and fieldname contains "inventory"
Strange, strange,... ](*,)0 -
Make sure to use...
CurrForm.UPDATECONROLS;
Everytime you change '1,5,,' + YourVariable's value !
I was fumbling on this and it just didn't seem to work until I finally tried UPDATECONTROLS.
Thank you kriki0 -
sorry for necroposting, but this helped me a lot and I would like to share my researches!
6.0 SP1 - still works for classic!
small example is below
made small list form to show dynamic caption fo Net Weight as "1 <base unit of measure> of <description> will weight" and values is lower:OBJECT Form 50000 Test Dynamic Caption { OBJECT-PROPERTIES { Date=16.05.11; Time=17:37:58; Modified=Yes; Version List=by AntidotE for Mibuso.com; } PROPERTIES { Width=12210; Height=5940; TableBoxID=50000; SourceTable=Table27; OnAfterGetCurrRecord=BEGIN BUoM := "Base Unit of Measure"; Desc := COPYSTR(Description,1,30); CurrForm.UPDATECONTROLS; END; } CONTROLS { { 50000;TableBox ;220 ;220 ;11770;5500 ;HorzGlue=Both; VertGlue=Both; HeadingHeight=880 } { 50001;TextBox ;0 ;0 ;1700 ;0 ;ParentControl=50000; InColumn=Yes; SourceExpr="No." } { 50002;Label ;0 ;0 ;0 ;0 ;ParentControl=50001; InColumnHeading=Yes } { 50003;TextBox ;0 ;0 ;3090 ;0 ;HorzGlue=Both; ParentControl=50000; InColumn=Yes; SourceExpr=Description } { 50004;Label ;0 ;0 ;0 ;0 ;ParentControl=50003; InColumnHeading=Yes } { 50009;TextBox ;7197 ;550 ;1320 ;440 ;ParentControl=50000; InColumn=Yes; SourceExpr="Base Unit of Measure" } { 50010;Label ;0 ;0 ;0 ;0 ;ParentControl=50009; InColumnHeading=Yes } { 50007;TextBox ;0 ;0 ;4290 ;0 ;ParentControl=50000; InColumn=Yes; SourceExpr="Net Weight"; CaptionClass=STRSUBSTNO(Text001,BUoM,Desc) } { 50008;Label ;0 ;0 ;0 ;0 ;ParentControl=50007; InColumnHeading=Yes } } CODE { VAR Text001@50000 : TextConst 'ENU=3,1 %1 of %2 will weigh'; BUoM@50001 : Code[10]; Desc@50002 : Text[30]; BEGIN END. } }
NB! take into account of limit of result caption length of 80!It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions