How to obtain length of a field

havhav Member Posts: 299
Hi all,
Does any onw of you know how to obtain the length of a field belonging to a given record. If yes, pls let me know.
The use case i am trying is - to handle overflow by comparing the lengths of two compatible fields.

Thsnks.


Regards,
Regards,
Hemant
MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)

Answers

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    MAXSTRLEN(recTable.Fieldname)
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • krikikriki Member, Moderator Posts: 9,118
    for knowing the max length of a field:
    MAXSTRLEN(recTable.Fieldname)

    for knowing the length of the value in the field:
    STRLEN(recTable.Fieldname)
    

    to copy some value in a field truncating it if needed:
    recTable.Fieldname := COPYSTR('Some Text',1,MAXSTRLEN(recTable.Fieldname));
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • havhav Member Posts: 299
    Yes you both are right.
    I got my answer and it is working.
    Thanx to both of you. :D
    Regards,
    Hemant
    MCTS (MB7-841 : NAV 2009 C/SIDE Solution Development)
Sign In or Register to comment.