How to send infolog or open a screen only for a specific user through code

Hi all,

I want to override insert method in a table and send infolog or open a screen only to a specific user.

A thought is to use sessionid but I do not know how.

Any help would be valuable.

Use Alerts - it doesn’t require writing any code.

I have a custom table and I prefer to send infolog to user. Is there any way…?

Also is there any way to refresh a form automatically when a record insert into table?

Thank you for your help.

Through cursuerid() method you can get the current user logged in. Override the insert method if you want to show the info log after the record is inserted.

You can compare the userid and can print the info log to a specific user.

For eg:

If( Curuserid() == “userid”)

{

info(“User is admin”);

}

For the form to get refreshed automatically you can use formds.research(); in your write method after overriding it on form datasource.

John, I thought that you want to send the notification to another user than who inserted the record. AnandMallavarapu7’s solution assumes that the infolog is shown to the user inseting a record, it merely shows it only to one specific user.

It’s not clear which approach is what you want - please clarify it.

Regarding refresh, refreshing data sources is trivial (FormDataSource.research()), the problem is that forms are not automatically notified about changes in database (assuming that you want to be notified about changes done by different users). One approach is using the Observer pattern (in AX 2012, you can use events), another solution may be refreshing the form automatically after certain amount of time.

Yes, I want to send the notification to different user than the one who inserted the record.

Alerts are there exactly for notifying users that something interesting happened, e.g. that a record was inserted. Use them unless you have a requirement that prevents you from doing that; you should explain the problem in such a case so we can think about a workaround.

I have tested Alerts, but there is a delay user’s notification. I want the user to be notified excactly when the record is inserted to custom table.

Then let clients to subscribe to an event that you’ll throw when the record is inserted. As as I already said, you can use events in AX 2012 or implement it by yourself using the Observer pattern.