web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

How To Create a notification by programming ?

(0) ShareShare
ReportReport
Posted on by 85

Hello,

Does anyone know how to create a new record of notification by programming?
What table should you create the record ?

If i look on pages, the part is a system part of notications id.

Thanks for help.


*This post is locked for comments

I have the same question (0)
  • Verified answer
    Saurav.Dhyani Profile Picture
    14,362 Super User 2025 Season 2 on at
    RE: How To Create a notification by programming ?

    Hi,

    Refer Standard Codeunit 454 "Job Queue - Send Notification". 

    This Codeunit creates Notification when you schedule posting of your Documents (Sales, Purchase) in Background.

    Hope this helps.

  • Verified answer
    Alexander Ermakov Profile Picture
    28,096 on at
    RE: How To Create a notification by programming ?

    I suppose you need Notification Entry table (msdn.microsoft.com/.../dn951728(v=nav.90).aspx ) and Sent Notification Entry table

    (msdn.microsoft.com/.../mt299614(v=nav.90).aspx )

    Theoretically, you are not limited to create new records in those tables in the same way as for the other tables, but can you tell what is the reason that you want to do this by programming?

  • Verified answer
    Community Member Profile Picture
    on at
    RE: How To Create a notification by programming ?

    Bonjour Matthieu,

    I need on the table NC header to create a notification everytime  the user generate a new non conformal product. 

    here is my piece of code that works like a charm into a codeunit



    LenChar := STRLEN(_Note);
    _RecRef.GETTABLE(pNCHeader);

    NewID := _RecRef.ADDLINK(GETURL(CLIENTTYPE::Current, COMPANYNAME, OBJECTTYPE::Page, PAGE::"NC Header", pNCHeader));

    RecordLink.GET(NewID);

    RecordLink.CALCFIELDS(Note);

    RecordLink.Note.CREATEOUTSTREAM(OStream);

    SystemUTF8Encoder := SystemUTF8Encoder.UTF8Encoding;
    SystemByteArray := SystemUTF8Encoder.GetBytes(_Note);

    x := SystemByteArray.Length DIV 128;
    IF x > 1 THEN
    y := SystemByteArray.Length - 128 * (x - 1)
    ELSE
    y := SystemByteArray.Length;
    c1 := y;
    OStream.WRITE(c1);
    IF x > 0 THEN BEGIN
    c2 := x;
    OStream.WRITE(c2);
    END;
    FOR i := 0 TO SystemByteArray.Length - 1 DO BEGIN
    c1 := SystemByteArray.GetValue(i);
    OStream.WRITE(c1);
    END;


    RecordLink.Type := RecordLink.Type::Note;
    RecordLink.Notify := _Notify;
    RecordLink."To User ID" := USERID;

    RecordLink.Created := CURRENTDATETIME;
    RecordLink.Company:=COMPANYNAME;

    RecordLink.MODIFY;

    the parameters are 

    Var Name DataType Subtype Length
    No pNCHeader Record NC Header
    No _Descritption Text 250
    No _Note Text 127
    No _Notify Boolean
    No _USERID Code 20

    the local variables are 

    Name DataType Subtype Length
    LenChar Integer
    NewID Integer
    RecordLink Record Record Link
    OStream OutStream
    _RecRef RecordRef
    SystemUTF8Encoder DotNet System.Text.UTF8Encoding.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    SystemByteArray DotNet System.Array.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    c1 Char
    c2 Char
    x Integer
    y Integer
    i Integer

    The hard part for me was to add text into the Note field because it is a blob field so I need to use the dot net library of the 4.5 framework and to stream the text. 

    J'espéré que ce code t'aidera autrement donne moi to enveloppe electronique et moi j'irai t'envoier une fob donc to pourra essaier le code.

    Piero 

  • Matthieu Corvaisier Profile Picture
    85 on at
    RE: How To Create a notification by programming ?

    Thank you for your answers.

    Pieror, I will try your method. I would come back to you.

    Alexander, I want to make this to prevent the "assigned user" of a sales order and also trace an action on the order.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#2
SC666 Profile Picture

SC666 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans