Global class is a standard class that contains a lot of small static functions. This post describes additional functions that extend it. To avoid using prefixes, all functions were added into the separate static class DEV. It exists in the DEVCommon model. As common practice, you can copy this class into your application as it is, or rename it according to your model name(e.g. ABC)
Copies one cursor to another using field names(standard buf2Buf uses IDs). So you can copy values between different tables
static void buf2Buf(Common _dest, Common _source, container _fieldsToExclude = conNull())
static void buf2BufMerge(Common _dest, Common _source)
The same functions as UnitofMeasureConverter::canBeConverted and ::convert but with the string parameters instead of RecIds
public static client server boolean canBeConverted(
UnitOfMeasureSymbol _fromUnitOfMeasure,
UnitOfMeasureSymbol _toUnitOfMeasure,
ItemId _ItemId)
Rounds the value according to unit settings
static Qty qty(Qty _qty, UnitOfMeasureSymbol _unit)
Casts parameter to Object
static Object cObject(Object _obj)
{ return _obj; }
Calculates the number of records in the query using Count(RecId). Standard SysQuery::countTotal switches to the loop mode when the query contains more than 1 DataSource.
static Integer countTotalQuick(QueryRun _queryRun)
Copies DataSource ranges
static void copyRanges(QueryBuildDataSource _qbdsTarget, QueryBuildDataSource _qbdsSource)
Gets a string, that contains all ranges values. Used in reports to display current filter values in the report header.
static Notes datasourceRangesAsText(QueryBuildDataSource _sourceDS)
Converts date to DateTime using UserPreferredTimeZone
static utcDateTime date2DateTime(TransDate _date, boolean _isEndOfDay = false)
static date dateTime2Date(utcDateTime _dateTime)
Returns the current date. It is still unclear for me, why the original method was marked as obsolete
static TransDate systemdateget()
{ return DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()); }
Returns the start of the week, the start of the year
static TransDate dateStartWk(TransDate _transDate)
static TransDate dateStartYr(TransDate _transDate)
Enable or disable all form DS fields, except specified
static void dsAllowEditExceptFields(FormDataSource _formDataSource, boolean _allowEdit, container _fieldListExclude=connull())
Get a list of the disabled fields. Used with the previous function when Datasource contains some code, that disables some fields, before dsAllowEditExceptFields call.
static container dsGetDisabledFields(FormDataSource _formDataSource)
Performs datasource refresh/research/executeQuery
static void dsRefresh(Common _record)
static void dsResearch(Common _record, NoYes _savePosition = NoYes::Yes)
static void dsExecuteQuery(Common _record, NoYes _savePosition = NoYes::Yes)
Gets the calling form from the current form args
static Object getFormRunFromFormArgs(FormRun _element, IdentifierName _formName)
Checks, that the query has a record. The common usage scenario is when you need to create a custom lookup for the field. In this case, you create a query for this lookup, create the lookup based on this query and add a check into the validateWrite() method to check that the entered value(user can enter the value using the manual entry) exists in this query
static boolean queryHasRecord(Query _q)
Is the current user included into the role
static boolean isUserInRole(Description _roleName)
Confirms a purchase order
static void purchTableConfirm(PurchTable _purchTable)
Executes menu item button with the specified record
static void runButtonWithRecord(FormFunctionButtonControl _button, Common _record,
Object _obj = null)
Validates the specified condition
static boolean validateCondition(anytype _condition, str _message, boolean _isThrowError = false)
Performs if (! A.RecId) {throw error("..")}
static void validateCursorIsNotEmpty(Common _common, str _someText = '')
Checks that the field is not empty and generates a message
static boolean validateCursorField(Common _table, fieldId _fieldId, boolean _isThrow = true)
Calls a validateWrite() method and generates an error if it fails
static void validateWriteRecordCheck(Common _record)
Merges 2 inventDim values
public static InventDim mergeInventDim(
InventDimGroupSetup _dimGroupSetup,
InventDim _fromInventDim,
InventDim _addedDim)
Displays the current value - info(StrFmt('%1',_i));, using mostly for debug purposes.
static void w(anytype _i, str _addition = '')
You can download this class using the following link https://github.com/TrudAX/XppTools/blob/master/DEVCommon/DEVCommon/AxClass/DEV.xml
If you know some other helpful functions feel free to create a GitHub pull request or leave a comment.
Similar posts: