How to create recordlink by C/AL-Code

RogerRoger Member Posts: 57
In NAV09 I'm able to create recordlinks manually including the possibility to generate a message for a specific user.

Now, I want to create such a recordlink with a message by using a C/AL function, but I don't know how.

Could anybody gives me some advices or hints?

Many thanks.
Many thanks, Roger

Answers

  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    The record links are stored in table 2000000068.

    The record id can be created with the GETVIEW I think, it is a combination of tablename and Primairy Key.
  • RogerRoger Member Posts: 57
    Thanks for tip.

    I've tried to use a test function which should write a recordlink like this
    Cont.GET('KT000001');
    RecRef.GETTABLE(Cont);
    CLEAR(RecordLink);
    RecordLink."Record ID" := RecRef.RECORDID;
    RecordLink.URL1 := 'dynamicsnav://......';
    RecordLink.Description := 'my Text';
    RecordLink.Type := RecordLink.Type::Note;
    
    Text.ADDTEXT('This is the text');
    RecordLink.Note.CREATEOUTSTREAM(OutStream);
    Text.WRITE(OutStream);
    
    RecordLink.Created := CURRENTDATETIME;
    RecordLink."User ID" := USERID;
    RecordLink.Company := COMPANYNAME;
    RecordLink.Notify := TRUE;
    RecordLink."To User ID" := USERID;
    RecordLink.INSERT(TRUE);
    

    The recordlink is visible in the role center, but the text is hidden. And if I click on the link, my client crashes and disappears.
    Many thanks, Roger
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    How about comparing your record to a manualy created record? Are there differences?
  • RogerRoger Member Posts: 57
    No, there are no differences except the text in the blob-field and teh description. Those are the texts which are not visible in the role center.
    Many thanks, Roger
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Then my guess would be that the blob contains something dat is not supported and causes the crash.

    (duh)

    Any chance of extracting the blobvalue of the manualy created record?
  • RogerRoger Member Posts: 57
    It seems that the manually created text in the blob has a leading special character, but which?

    If I read the blob in an text variable and show it by a message box, so I receive the follows (see attachement)
    Many thanks, Roger
  • DenSterDenSter Member Posts: 8,307
    Search the C/SIDE Reference Guide for 'recordid', there are code samples in there. It is a data type as well as a recordref function. As soon as you load the right record into the recordref, it is a simple matter of assigning the value.
  • RogerRoger Member Posts: 57
    DenSter wrote:
    Search the C/SIDE Reference Guide for 'recordid', there are code samples in there. It is a data type as well as a recordref function. As soon as you load the right record into the recordref, it is a simple matter of assigning the value.

    The problem is not the recordid, I mean. The problem is the text into the blob-field which is not shown on the rolecenter startpage
    Many thanks, Roger
  • UdAkunuriUdAkunuri Member Posts: 31
    I think, instead of writing code to insert the links, You can use ADDLINK function of the record variable
    Thanks & Regards,
    Udaykumar Akunuri
  • RogerRoger Member Posts: 57
    UdAkunuri wrote:
    I think, instead of writing code to insert the links, You can use ADDLINK function of the record variable

    Thank you, UdAkunuri. With the ADDLINK function it is very easier to create a link, it works well.

    But I have still the problem with the blob field 'Note'. If I write text in it, the client crashes if I try to cklick the new link in the rolecenter.
    Many thanks, Roger
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    What about reading the 'weird' character from the orriginal blob, store it in a setup table and use it when creating your own?
  • RogerRoger Member Posts: 57
    Yes, this works well. The record link is correct an can be used.

    The field in the setup table has this value:

    Test

    There is a leading character which I don't know
    Many thanks, Roger
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Ok, so issue 'Solved'?

    I reccomend reporting this issue to Microsoft to they can make a proper solution for this. Next time I meet the program managers I will also mention this. (If I remember. :mrgreen: ).
  • RogerRoger Member Posts: 57
    The problem is almost solved.

    I've used the following code. I have to store a TAB-Character in front of my text in order to
    receive a recordlink which are works
    Tab := 9;
    Text := FORMAT(Tab) + 'There is another useful hint';
    
    Cont.GET('1000');
    NewID := Cont.ADDLINK('dynamicsnav://dell-rotsch:7046/myCharity/myCharity/runpage?page=5050&mode=Edit',
                          'Created in a own function');
    
    RecordLink.GET(NewID);
    RecordLink.CALCFIELDS(Note);
    RecordLink.Note.CREATEOUTSTREAM(OutStream);
    OutStream.WRITE(Text);
    RecordLink.Type := RecordLink.Type::Note;
    RecordLink.Notify := TRUE;
    RecordLink."To User ID" := USERID;
    RecordLink.MODIFY;
    

    But the system cuts my text which is shown in the role center.
    Instead 'There is another useful hint' I see only 'There is'

    Quite strange :roll:
    Many thanks, Roger
  • RogerRoger Member Posts: 57
    OK, I solved the problem! :D

    The blob wants to know how long the text is that you want to write in it. The length must be store in a variable of type CHAR.

    So, my test function works as I expected from like this:
    Text := 'Dies ist ein weiterer wertvoller Hinweis';
    LenChar := STRLEN(Text);
    
    Text := FORMAT(LenChar) + Text;
    
    Cont.GET('1000');
    NewID := Cont.ADDLINK('dynamicsnav://dell-rotsch:7046/myCharity/myCharity/runpage?page=5050&mode=Edit',
                          'Über eigene Funktion erstellt');
    
    RecordLink.GET(NewID);
    
    RecordLink.CALCFIELDS(Note);
    RecordLink.Note.CREATEOUTSTREAM(OutStream);
    OutStream.WRITE(Text);
    
    RecordLink.Type := RecordLink.Type::Note;
    RecordLink.Notify := TRUE;
    RecordLink."To User ID" := USERID;
    
    RecordLink.MODIFY;
    

    Thanks to all for helping me :)
    Many thanks, Roger
  • Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Please post this to the Tips and Tricks section of this forum.

    Glad it works. =D>
  • RogerRoger Member Posts: 57
    OK, I've done it
    Many thanks, Roger
  • mbriccombricco Member Posts: 7
    I've copied Roger's code to insert record links but get these results in the Notes field-
    6The Expected Receipt Date on Purchase Order 106004 Line

    I was expecting -
    The Expected Receipt Date on Purchase Order 106004 Line 10000 was changed to 04/28/11.

    I know a special character is written in the first position in the blob. Short of having a lookup table or array, how do I get the special character and my entire string?
  • RogerRoger Member Posts: 57
    I've got tested my function and I don't found a failure.

    As the follow I've implemented it in my solution. Hope, this helps
    CreateNotifyEntry(VAR _RecRef : RecordRef;_Description : Text[250];_Note : Text[1024];_Notify : Boolean;_UserID : Code[20])
    LenChar := STRLEN(_Note);
    
    NewID := _RecRef.ADDLINK('dynamicsnav://///runpage?page=5050&mode=Edit', _Description);
    
    RecordLink.GET(NewID);
    
    RecordLink.CALCFIELDS(Note);
    RecordLink.Note.CREATEOUTSTREAM(OStream);
    OStream.WRITE(FORMAT(LenChar) + _Note);
    RecordLink.Type := RecordLink.Type::Note;
    RecordLink.Notify := _Notify;
    RecordLink."To User ID" := _UserID;
    
    RecordLink.MODIFY;
    
    Many thanks, Roger
  • thuntthunt Member Posts: 5
    I've actually been working on a project to convert records from the Comment Line table (related to a custom table) into NAV Notes/Record Links related to records in a table for an add-on. I'm combining the old Comment Lines to create consolidated notes, but I can't seem to get more than 128 characters to write at a time. ](*,)

    I suspect this is related to the fact that the standard ASCII character set is 128, although I could be totally off base. I know that the notes can be more than 128 characters--it's a BLOB field, so it should handle anything up to 2 gigs. I just have no idea how to get more than 128 characters in there. Does anyone know? Am I blazing a trail and becoming the first person who's done this? (Or at least the first person willing to publicly admit that I don't know how to do it?)
  • krzychub83krzychub83 Member Posts: 120
    Solution is different between 2009 and 2013. Please use google/bing for NAV 2009, as I remember seeing something for this problem already.

    For 2013/R2 algorithm has changed a bit and values returned there do not show simple correlation. However there is a workaround. For notes having length < 128 the first char is length of the note. For notes having length >= 128 the first char can be assigned based on static values. You can use NAV to create 128 notes having length between 128 and 255. You can get first char value out of those notes. This will give you 128 chars, which you then reuse every 128 characters (note length MOD 128). Second char is simple length DIV 128. This is a very dirty workaround, but it seemed to be working when I was looking into this problem. I don't remember having any issues with it. Just play with it and see if it does work for you.
  • tarique9609tarique9609 Member Posts: 1
    where to write the code ???
Sign In or Register to comment.