Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

What type of class for a utility or common class ?

(0) ShareShare
ReportReport
Posted on by 522
Hi everyone,
 
I want to create a common class or utility class that the purpose is to record some activity with its timestamp in a log table. So basically this utility class will be called in several of my other classes.
I created something like this:
class MyGlobalClass{    public static void insertToLog(str _classname, str _methodname, Notes _param)    {        MyLogTable   logTable;        System.DateTime localDateTime = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::getSystemDateTime(), DateTimeUtil::getUserPreferredTimeZone());                ttsbegin;                        logTable.clear();        logTable.ID = localDateTime.ToString('yyyyMdd_HHmmss');        logTable.ActionDate = DateTimeUtil::date(localDateTime);        logTable.ClassName = strFmt(/%1 - %2/, _classname, _methodname);        logTable.InputParameter =  _param;        logTable.insert();                ttscommit;    }}
 
I'm wonder if this is the correct way? 
And how to use this in my other class ? because currently, after successfully build, when I type this in the class that I wanted, the Intellisense didn't show this /MyGlobalClass/
Is there something wrong like the type of class ? 
 
Btw, why it is very hard now to put code in this thread with the new UI ? I'm choosing C++ for the language just now because there is no X++  :)
 
 
Thanks,
 
  • Ken Manhattan Profile Picture
    522 on at
    What type of class for a utility or common class ?
    Yeah, Build again and restart Visual Studio done it. Thanks.
  • Verified answer
    Martin Dráb Profile Picture
    231,723 Most Valuable Professional on at
    What type of class for a utility or common class ?
    It looks fine to me. Check out if the call of MyGlobalClass::insertToLog(...) compiles correctly. If so, you have a problem with IntelliSense, not with visibility of the class. If not, make sure that you're using in the same module or that the module has a reference to the one containing MyGlobalClass. If that's all right, look at the error message provided by the compiler.
     
    If the class is supposed to contain static methods only, you can make the whole class static, to make it explicit.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,863 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans