Create alert through code on button click in D365FO

Hi,

I am creating alert notification using below code in D365F&O through code on button click but its not inserting any record in EventInbox table not showing any notification in action center on running of change based alert batch job

        EventNotification event = EventNotification::construct(EventNotificationSource::Batch);
        CaseStatusSetup casestatus;
        ;

        select casestatus where casestatus.CaseStatus == "Created";// Passing the item number for which we are going to show the alert

        event.parmRecord(casestatus); // Name of the table
        event.parmUserId(curuserid()); // User for which this alert has to be shown
        event.parmDataSourceName("CaseStatusSetup"); //The form datasource
        event.parmMenuFunction(new MenuFunction("CaseStatusSetup", MenuItemtype::Display));
        event.parmSubject("Test"); //Subject of the alert
        event.parmMessage("Test Event alert"); // Message of the alert
        event.create(); // Alert creation

I tried to do the same using below code as well it is inserting record in EventInbox table but on running of change based alert batch job it not showing notification for specific user on Action Center.

        EventInbox          inbox;
        ;
        inbox.initValue();

        inbox.ShowPopup     = NoYes::Yes;
        inbox.Subject       = "This is the Alert subject";
        inbox.Message       = "This is the Alert message";
        inbox.AlertedFor    = "This alert is just information no links are available";
        inbox.SendEmail     = false;
        inbox.UserId        = curUserId();
        inbox.TypeId        = classnum(EventTypeCUD);
        inbox.AlertTableId  = tablenum(CaseStatusSetup);
        inbox.AlertFieldId  = fieldnum(CaseStatusSetup, DocumentTYpe);
        inbox.TypeTrigger   = EventTypeTrigger::FieldChanged;
        inbox.CompanyId     = curext();
        inbox.ParentTableId = tableNum(CaseStatusSetup);
        inbox.InboxId       = EventInbox::nextEventId();;
        inbox.AlertCreatedDateTime = DateTimeUtil::getSystemDateTime();
        //inbox.Visible      = NoYes::Yes;
        inbox.insert();

Am i missing something ?