@Formula Snippet – Strip leading zeros from @NoteId

We use @NoteId in a view to get the NoteId of a document and display the value in a column. Via NotesNavigator, we access this column ( and others ) Unfortunately, the value, that is returned by the formula is something like NT0000903.

When we pass this value to our function, to open the document in a tabContainer, it fails because the function excepts only the number part wthout the NT and leading zeros. ( = 903 ). So I was looking for a way to stip the unwanted part from the string.

Here is, what I came out with

tmp:=@ReplaceSubstring(@NoteID;"NT";"");
@Do(tmp := tmp;@While(@Length(tmp) > 1 & @Begins(tmp; "0");tmp := @Middle(tmp; 1; 8));tmp) ;

If there is a better solution, let me know. We tried many things, but to go thru the value from left to right and checking, if the string begins with a “0” seems to be the best way to achieve the aim.

17 thoughts on “@Formula Snippet – Strip leading zeros from @NoteId

  1. I just cheat. @ReplaceSubstring(@NoteID; “NT00000″:”NT0000″:”NT000″:”NT00″:”NT0”; “”)

  2. Who cares if it’s not professional… so long as it works and processes faster than a while loop. 🙂

  3. Similar solution only with @for. In case you have a “high” NoteId, it might be faster I guess 🙂

    _Tmp:=@ReplaceSubstring(@NoteID;”NT”;””);
    _Len := @length(_tmp);
    @For(x := 0 ; x =< _len ; x:=x+1;
    @If(@Middle(_tmp;x;1) “0”;
    @Do(
    @Set(“_Tmp”;@Right(_tmp;_len-x));
    x := _Len
    )
    ;””)
    );
    _Tmp

    Since you said you have to use it in a view, you can’t use @return, Otherwise the @do / @set could be replaced with a @return

  4. What do you think about this solution:

    _NoneNT:= @Right (“NT001001AE”; 8);
    _NoneZero:= @Trim(@ReplaceSubstring(_NoneNT; “0”; “”));
    @Left(_NoneZero; 1) + @Right (_NoneNT; @Left(_NoneZero; 1));

  5. Ups, @Trim is not necessary

    _NoneNT:= @Right (“NT001001AE”; 8);
    _NoneZero:= @ReplaceSubstring(_NoneNT; “0”; “”);
    @Left(_NoneZero; 1) + @Right (_NoneNT; @Left(_NoneZero; 1));

Comments are closed.