DSPUtil d365fo x++
DSPUtil d365fo x++
Code:
class DSPUtil
{
private static DSPUtil utilObject;
public static DSPUtil construct()
{
if(!utilObject)
utilObject = new DSPUtil();
return utilObject;
}
public void openDocumentAttachmentForm(Object _caller, Common _record)
{
if (_record)
{
Args args = new Args(menuItemDisplayStr(DocuView));
args.caller(_caller);
args.record(_record);
args.menuItemName(menuitemDisplayStr(DocuView));
args.menuItemType(MenuItemType::Display);
FormRun formRun = classfactory.formRunClass(args);
formRun.init();
formRun.run();
formRun.wait();
}
}
public boolean isRoleAttachedWithCurrentUser(str _aotName)
{
boolean ret;
SecurityRole role;
SecurityUserRole userRole;
;
select firstonly1 role
exists join userRole
where role.RecID == userRole.SecurityRole
&& role.AotName == _aotName
&& userRole.User == curUserId();
ret = (role) ? true : false;
return ret;
}
public boolean isWorkflowConfigured(WorkflowTypeName _workflowTypeName)
{
boolean ret;
WorkflowTable workflowTable = WorkflowTable::findActiveTemplate(_workflowTypeName);
if(workflowTable)
{
ret = (workflowTable.AssociationType == WorkflowAssociationType::Global) ? true : this.isActiveWorkflowForCurrentCompanyExists(_workflowTypeName);
}
return ret;
}
public boolean isActiveWorkflowForCurrentCompanyExists(WorkflowTypeName _workflowTypeName)
{
WorkflowTable workflowTable;
WorkflowVersionTable workflowVersionTable;
select firstonly workflowTable
exists join workflowVersionTable
where workflowTable.TemplateName == _workflowTypeName
&& workflowTable.Type == WorkflowConfigurationType::Definition
&& workflowTable.AssociationType == WorkflowAssociationType::Company
&& workflowTable.DataArea == curExt()
&& workflowVersionTable.WorkflowTable == workflowTable.RecId
&& workflowVersionTable.Enabled == NoYes::Yes;
return workflowTable.RecId;
}
public boolean isWorkflowConfigured_OLD(WorkflowTypeName _workflowTypeName)
{
boolean ret = false;
WorkflowTable workflowTable;
WorkflowVersionTable versionTable;
select firstonly RecId, DataArea, AssociationType from workflowTable
where workflowTable.Type == WorkflowConfigurationType::Definition
&& workflowTable.TemplateName == _workflowTypeName
exists join versionTable
where versionTable.WorkflowTable == workflowTable.RecId
&& versionTable.Enabled == NoYes::Yes;
if(workflowTable.AssociationType == WorkflowAssociationType::Global)
{
ret = workflowTable.RecId != 0;
}
else
{
ret = (workflowTable.DataArea == curExt());
}
return ret;
}
public int getNumberOfAttachments(RefRecId _refRecId, TableId _tableId, SelectableDataArea _company = curExt())
{
DocuRef docuRef;
DocuValue docuValue;
int documentCounter;
select count(RecId) from docuRef
where docuRef.RefRecId == _refRecId
&& docuRef.RefTableId == _tableId
&& docuRef.RefCompanyId == _company;
documentCounter = docuRef.RecId;
return documentCounter;
}
// This is only for entitlement period calculation
// Count month if month is passed or month is at last
public Months getNumberOfMonths(DSPStartDate _startDate, DSPEndDate _endDate)
{
Months numberOfMonths;
Days numberOfDays;
DSPStartDate startDate;
DSPEndDate endDate;
DSPStartDate startOfMonthStartDate;
DSPEndDate startOfMonthEndDate;
MonthsOfYear monthOfYear;
const int MIN_DATE = 28;
const int MAX_DATE = 31;
const int MID_DATE = 30;
;
endDate = _endDate;
startDate = _startDate;
if(startDate < endDate)
{
startOfMonthEndDate = (dateEndMth(endDate) == endDate) ? endDate + 1 : dateStartMth(endDate);
startOfMonthStartDate = dateStartMth(startDate);
while(startOfMonthStartDate < startOfMonthEndDate)
{
numberOfMonths++;
startOfMonthStartDate = nextmth(startOfMonthStartDate);
}
if(!numberOfMonths)
{
numberOfDays = endDate - startDate + 1;
switch(mthOfYr(endDate))
{
case MonthsOfYear::January:
case MonthsOfYear::March:
case MonthsOfYear::May:
case MonthsOfYear::July:
case MonthsOfYear::August:
case MonthsOfYear::October:
case MonthsOfYear::December:
numberOfMonths += (numberOfDays == MAX_DATE) ? 1 : 0;
break;
case MonthsOfYear::February:
numberOfMonths += (numberOfDays == MIN_DATE) ? 1 : 0;
break;
case MonthsOfYear::April:
case MonthsOfYear::June:
case MonthsOfYear::September:
case MonthsOfYear::November:
numberOfMonths += (numberOfDays == MID_DATE) ? 1 : 0;
break;
}
}
}
return numberOfMonths;
}
public static void lookupTable(FormControl _fCtrl, TableId _tableId, Query _query)
{
Query query;
FormControl formControl;
TableId tableId;
SysTableLookup tableLookup;
DictTable dictTable;
DictFieldGroup fieldGroup;
FieldId fieldId;
;
query = _query;
tableId = _tableId;
formControl = _fCtrl;
dictTable = new SysDictTable(tableId);
fieldGroup = new DictFieldGroup(tableId, 'AutoLookup');
tableLookup = SysTableLookup::newParameters(tableId, formControl);
for (int i = 1; i <= fieldGroup.numberOfFields(); i++)
{
if (fieldGroup && fieldGroup.numberOfFields())
{
fieldId = fieldGroup.field(i);
if(fieldId)
{
tableLookup.addLookupfield(fieldId);
}
}
}
if(query)
tableLookup.parmQuery(query);
tableLookup.performFormLookup();
}
List getFieldGroupFieldList(TableId _tableId, str _fieldGroupName)
{
List fieldList;
TableId tableId;
FieldId fieldId;
str fieldGroupName;
DictTable dictTable;
DictFieldGroup fieldGroup;
;
fieldList = new List(Types::Integer);
tableId = _tableId;
fieldGroupName = _fieldGroupName;
dictTable = new SysDictTable(tableId);
fieldGroup = new DictFieldGroup(tableId, fieldGroupName);
for (int i = 1; i <= fieldGroup.numberOfFields(); i++)
{
if (fieldGroup && fieldGroup.numberOfFields())
{
fieldId = fieldGroup.field(i);
if(fieldId)
{
fieldList.addEnd(fieldId);
}
}
}
return fieldList;
}
public str getRecordTitleField(Common _record, boolean _getFirst = true)
{
DictTable dictTable;
Common record;
TableId tableId;
FieldId titleFieldId;
str titleFieldValue;
;
record = _record;
tableId = record.TableId;
if(record && tableId)
{
dictTable = new SysDictTable(tableId);
titleFieldId = (_getFirst) ? dictTable.titleField1() : dictTable.titleField2();
titleFieldValue = (titleFieldId) ? record.(titleFieldId) : '';
}
return titleFieldValue;
}
public str getRecordTitleFields(Common _record)
{
str title1;
str title2;
str recordTitle;
;
title1 = this.getRecordTitleField(_record);
title2 = this.getRecordTitleField(_record, false);
title2 = (title1 && title2) ? strFmt(' - %1', title2) : title2;
recordTitle = strFmt('%1%2', title1, title2);
return recordTitle;
}
public static boolean isCalledFromWorkFlow(FormRun _fRun)
{
boolean ret;
FormRun fRun;
FormDataSource formDataSource;
MenuItemName callerMenuItem;
MenuItemName workFlowMenuItem;
Common dataSourceRecord;
;
fRun = _fRun;
formDataSource = fRun.dataSource();
dataSourceRecord = formDataSource.cursor();
workFlowMenuItem = new DSPWorkflowUtil().getWorkFlowDocumentMenuItem(fRun);
callerMenuItem = DSPUtil::callerMenuItem(fRun);
ret = (callerMenuItem == workFlowMenuItem);
return ret;
}
public static MenuItemName callerMenuItem(FormRun _fRun)
{
FormRun fRun;
MenuItemName callerMenuItem;
;
fRun = _fRun;
if(fRun)
{
callerMenuItem = fRun.args().menuItemName();
}
return callerMenuItem;
}
public static void refreshCaller(FormRun _fRun)
{
FormRun callerForm;
;
callerForm = _fRun.args().caller();
if(callerForm)
{
DSPUtil::refreshForm(callerForm);
}
}
public static void refreshForm(FormRun _fRun)
{
FormDataSource fds;
;
if(_fRun)
{
fds = _fRun.dataSource();
DSPUtil::refreshDataSource(fds);
}
}
public static void refreshDataSource(FormDataSource _fds)
{
FormDataSource fds;
;
fds = _fds;
if(fds)
{
fds.refresh();
fds.reread();
fds.research(true);
}
}
public static void showInfo(boolean _show, str _info)
{
if(_show)
info(_info);
}
public static void showWarning(boolean _show, str _warning)
{
if(_show)
warning(_warning);
}
public static void showError(boolean _show, str _error)
{
if(_show)
error(_error);
}
public static void throwError(boolean _throw, str _error)
{
if(_throw)
throw error(_error);
}
public static boolean isEmployeeHasUserAttached(HcmPersonnelNumberId _personnelNumberId)
{
boolean ret;
HcmWorker worker;
DirPersonUser personUser;
UserId userId;
HcmPersonnelNumberId personnelNumberId;
;
personnelNumberId = _personnelNumberId;
// Verify selected worker has user attached
if(personnelNumberId)
{
select firstonly1 User
from personUser
join worker
where personUser.PersonParty == worker.Person
&& worker.PersonnelNumber == personnelNumberId;
userId = personUser.User;
ret = (userId) ? true : false;
}
return ret;
}
public Common findRecord(TableId _tableId, RecId _recId, Boolean _forUpdate = false)
{
Common common;
DictTable dictTable;
;
dictTable = new DictTable(_tableId);
common = dictTable.makeRecord();
common.selectForUpdate(_forUpdate);
select common
where common.RecId == _recId;
return common;
}
public Common findRecordWithSelectedFields(RefTableId _tableId, str _filterField, System.Object _filterValue, container _selectionFields)
{
str filterField;
Common tableBuffer;
DictTable dictTable;
TableId tableId;
System.Object filterValue;
System.Object filterValRaw; // Raw filter value
SysDaQueryObject sysDaQuery;
SysDaSearchObject searchObject;
container selectionFields;
List selectionFieldList;
ListEnumerator enumerator;
;
filterField = _filterField;
filterValRaw= _filterValue;
tableId = _tableId;
dictTable = new DictTable(tableId);
tableBuffer = dictTable.makeRecord();
sysDaQuery = new SysDaQueryObject(tableBuffer);
selectionFields = _selectionFields;
// to avoid unauthorize data fetching
if(filterField && filterValue)
{
selectionFieldList = con2List(selectionFields);
enumerator = selectionFieldList.getEnumerator();
while(enumerator.moveNext())
{
sysDaQuery.projection().add(any2Str(enumerator.current()));
}
sysDaQuery.firstOnlyHint = true;
sysDaQuery.whereClause(new SysDaEqualsExpression (new SysDaFieldExpression(tableBuffer, filterField), new SysDaValueExpression(filterValue)));
searchObject = new SysDaSearchObject(sysDaQuery);
}
return tableBuffer;
}
public void updateValue(TableId _tableId, RecId _recId, str _field, AnyType _value)
{
Common common;
Int fieldId;
;
ttsbegin;
common = this.findRecord(_tableId, _recId, true);
fieldId = fieldname2id(_tableId,_field);
if (fieldId && _value)
{
common.(fieldId) = _value;
common.update();
}
ttscommit;
}
public DSPEmployeeId getFieldValueFromRecord(TableId _tableId, RecId _recId, int _fieldId)
{
anytype fieldValue;
DSPEmployeeId employeeId;
;
fieldValue = this.findRecord(_tableId, _recId).(_fieldId);
employeeId = any2Str(fieldValue);
return employeeId;
}
public str getInfoLog()
{
str error;
Exception exception;
SysInfologEnumerator enumerator;
SysInfologMessageStruct msgStruct;
enumerator = SysInfologEnumerator::newData(infolog.cut());
while (enumerator.moveNext())
{
msgStruct = new SysInfologMessageStruct(enumerator.currentMessage());
exception = enumerator.currentException();
error = strfmt("@DSPLabel:DSP002388", error, msgStruct.message());
}
return error;
}
public boolean tableHasMethod(RefTableId _refTableId, IdentifierName _methodName)
{
return SysDictTable::hasMethod(new SysDictTable(_refTableId), _methodName);
}
public boolean isEditable(Common _common)
{
boolean ret;
SysDictTable dictTable;
RefTableId tableId;
RefRecId recId;
boolean hasMethod;
IdentifierName methodName;
DictTable dt;
;
methodName = 'isEditable';
if(_common)
{
tableId = _common.TableId;
recId = _common.RecId;
dictTable = new SysDictTable(tableId);
hasMethod = SysDictTable::hasMethod(dictTable, methodName);
if(hasMethod)
{
ret = dictTable.callObject(methodName, _common);
}
}
return ret;
}
public boolean isValidToSubmit(Common _common)
{
boolean ret = true;
SysDictTable dictTable;
RefTableId tableId;
RefRecId recId;
boolean hasValidToSubmitMethod;
IdentifierName methodName;
DictTable dt;
;
methodName = 'isValidToSubmit';
if(_common)
{
tableId = _common.TableId;
recId = _common.RecId;
dictTable = new SysDictTable(tableId);
hasValidToSubmitMethod = SysDictTable::hasMethod(dictTable, methodName);
if(hasValidToSubmitMethod)
{
ret = dictTable.callObject(methodName, _common);
}
}
return ret;
}
private void copyAttachments(Common _fromBuffer, Common _toBuffer)
{
Common fromBuffer;
Common toBuffer;
DocuRef fromDocuRef;
DocuRef toDocuRef;
RecordInsertList insertList;
;
fromBuffer = _fromBuffer;
toBuffer = _toBuffer;
insertList = new RecordInsertList(tableNum(DocuRef));
if(fromBuffer && toBuffer)
{
while select fromDocuRef
where fromDocuRef.RefTableId == fromBuffer.TableId
&& fromDocuRef.RefRecId == fromBuffer.RecId
{
buf2Buf(fromDocuRef, toDocuRef);
toDocuRef.RefRecId = toBuffer.RecId;
toDocuRef.RefTableId = toBuffer.TableId;
toDocuRef.RefCompanyId = curExt();
insertList.add(toDocuRef);
}
insertList.insertDatabase();
}
}
public str getNumberSequence(ExtendedTypeId _edt)
{
str numberSequenceID;
SysLastValue sysLastValue;
NumberSequenceReference numberSequenceReference = NumberSeqReference::findReference(_edt);
NumberSequenceTable numberSequenceTable = NumberSequenceTable::find(numberSequenceReference.NumberSequenceId);
if (numberSequenceReference && numberSequenceTable)
{
if(!numberSequenceTable.Manual)
{
NumberSeq numberSeq = NumberSeq::newGetNumFromId(numberSequenceTable.RecId,true,true,sysLastValue,false);
numberSequenceID = (numberSeq) ? numberSeq.num() : '';
}
}
return numberSequenceID;
}
public container getMapKeyToContainer(Map _map)
{
container mapContainer;
if(_map)
{
MapEnumerator mapEnumerator = _map.getEnumerator();
while(mapEnumerator.moveNext())
{
mapContainer += any2Str(mapEnumerator.currentKey());
}
}
return mapContainer;
}
public container getMapValueToContainer(Map _map)
{
container mapContainer;
if(_map)
{
MapEnumerator mapEnumerator = _map.getEnumerator();
while(mapEnumerator.moveNext())
{
mapContainer += any2Str(mapEnumerator.currentValue());
}
}
return mapContainer;
}
// _reportExportable pass object of controller class which implements DSPIReportExportable
// _filename is the name of PDF file to be export
// _args is the same Args which is passed by the main method in controller class
public System.IO.MemoryStream getReportPDF(DSPIReportExportable _reportExportable, Filename _filename, Args _args)
{
Args args;
System.IO.MemoryStream stream;
DSPIReportExportable reportExportable;
Filename fileName;
ReportName reportName;
SrsReportRunController controller;
SRSPrintDestinationSettings settings;
Array arrayFiles;
System.Byte[] reportBytes = new System.Byte[0]();
SRSProxy srsProxy;
SRSReportRunService srsReportRunService = new SrsReportRunService();
Microsoft.Dynamics.AX.Framework.Reporting.Shared.ReportingService.ParameterValue[] parameterValueArray;
Map reportParametersMap;
SRSReportExecutionInfo executionInfo = new SRSReportExecutionInfo();
args = _args;
filename = _filename;
reportExportable = _reportExportable;
controller = reportExportable.getController();
reportName = reportExportable.getReportName(args);
if(controller && reportName)
{
controller.parmArgs(args);
controller.parmReportName(reportName);
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);
//controller.prePromptModifyContract();
reportExportable.callPreRunModifyContract();
reportExportable.callPrePromptModifyContract();
settings = controller.parmReportContract().parmPrintSettings();
settings.printMediumType(SRSPrintMediumType::File);
settings.fileName(fileName);
settings.fileFormat(SRSReportFileFormat::PDF);
controller.parmReportContract().parmReportServerConfig(SRSConfiguration::getDefaultServerConfiguration());
controller.parmReportContract().parmReportExecutionInfo(executionInfo);
srsReportRunService.getReportDataContract(controller.parmreportcontract().parmReportName());
srsReportRunService.preRunReport(controller.parmreportcontract());
reportParametersMap = srsReportRunService.createParamMapFromContract(controller.parmReportContract());
parameterValueArray = SrsReportRunUtil::getParameterValueArray(reportParametersMap);
srsProxy = SRSProxy::constructWithConfiguration(controller.parmReportContract().parmReportServerConfig());
// Actual rendering to byte array
reportBytes = srsproxy.renderReportToByteArray(controller.parmreportcontract().parmreportpath(),
parameterValueArray,
settings.fileFormat(),
settings.deviceinfo());
if (reportBytes)
{
stream = new System.IO.MemoryStream(reportBytes);
}
}
return stream;
}
public System.IO.MemoryStream getStreamOfDocument(DocuTemplate template, str entityName, str filterField, anyType filterValue)
{
Map filtersToApply = new Map(Types::String, Types::Class);
DocuTemplateRender renderer = new DocuTemplateRender();
System.IO.MemoryStream attachmentStream = new System.IO.MemoryStream();
ExportToExcelFilterTreeBuilder filterTreeBuilder = new ExportToExcelFilterTreeBuilder(entityName);
var applicationIdFilter = filterTreeBuilder.areEqual(filterField, filterValue);
filtersToApply.insert(entityName, applicationIdFilter);
renderer.renderTemplateToStream(template, filtersToApply, attachmentStream, OfficeTrimmable::construct());
attachmentStream.Seek(0, System.IO.SeekOrigin::Begin);
return attachmentStream;
}
public str getHijriDate(TransDate _date)
{
int gDate,gMonth,gYear;
gDate = dayOfMth(_date);
gMonth = mthOfYr(_date);
gYear = year(_date);
System.Globalization.CultureInfo arCul = new System.Globalization.CultureInfo('ar-SA');
System.DateTime dt = new System.DateTime(gYear, gMonth, gDate);
str s = dt.ToString('M/dd/yyyy', arCul);
return s;
}
public void addDataEntityInOfficeMenu(OfficeMenuEventArgs _eventArgs, str _dataEntityName, int _dataSourceId = OfficeExportMenuItem::NoDataSourceSpecifiedId)
{
OfficeMenuDataEntityOptions menuDataEntityOptions = OfficeMenuDataEntityOptions::construct(_dataEntityName);
menuDataEntityOptions.dataSourceIdInternal(_dataSourceId);
_eventArgs.menuOptions().dataEntityOptions().addEnd(menuDataEntityOptions);
}
public container getClassMethodsContainer(ClassName _className)
{
container methodContainer;
SysDictClass sysDictClass = new SysDictClass(className2Id(_className));
Set methodSet = sysDictClass.methods(true, true, false);
if(methodSet)
{
SetEnumerator enumerator = methodSet.getEnumerator();
while(enumerator.moveNext())
{
DictMethod dictMethod = enumerator.current();
methodContainer += dictMethod.name();
}
}
return methodContainer;
}
public container getTableMethodsContainer(TableName _tableName)
{
container methodContainer;
SysDictTable sysDictTable = new SysDictTable(tableName2Id(_tableName));
Set methodSet = sysDictTable.methods(true, true, false);
if(methodSet)
{
SetEnumerator enumerator = methodSet.getEnumerator();
while(enumerator.moveNext())
{
DictMethod dictMethod = enumerator.current();
methodContainer += dictMethod.name();
}
}
return methodContainer;
}
public void lookupFormForContainer(FormStringControl _ctrl, container _container, str _caption)
{
#ResAppl
FormRun formRun;
formRun = classFactory.createSysLookupPicklist();
formRun.init();
formRun.choices(_container, #ImageTable);
formRun.caption(_caption);
_ctrl.performFormLookup(formRun);
}
public void lookupClassMethods(FormStringControl _ctrl, ClassName _className)
{
#ResAppl
FormRun formRun;
formRun = classFactory.createSysLookupPicklist();
formRun.init();
formRun.choices(this.getClassMethodsContainer(_className), #ImageTable);
formRun.caption("@DSPLabel:DSP002364");
_ctrl.performFormLookup(formRun);
}
public boolean isDevForm(FormRun fRun)
{
boolean ret;
;
if(fRun)
{
ret = strContains(fRun.args().menuItemName(), 'Dev');
}
return ret;
}
public Name getSubmittedBy(Common _record)
{
Name name;
name = this.callClassMethod(className2Id('DSSWorkflowUtil'), 'getSubmittedBy', true, _record);
return name;
}
public str getLastApprover(Common _record)
{
str name;
name = this.callClassMethod(className2Id('DSSWorkflowUtil'), 'getLastApprover', true, _record);
return name;
}
public str getApproverNames(Common _record)
{
str name;
name = this.callClassMethod(className2Id('DSSWorkflowUtil'), 'getApproverNames', true, _record);
return name;
}
public str getApproverNamesWithDates(Common _record)
{
str name;
name = this.callClassMethod(className2Id('DSSWorkflowUtil'), 'getApproverNamesWithDates', true, _record);
return name;
}
public str getWorkflowApproversWithComments(Common _record)
{
str name;
name = this.callClassMethod(className2Id('DSSWorkflowUtil'), 'getWorkflowApproversWithComments', true, _record);
return name;
}
public anytype callClassMethod(ClassId _classId, MethodName _methodName, boolean isInstanceMethod, Common _record)
{
anytype returnObject;
SysDictClass dictClass = new SysDictClass(_classId);
if(isInstanceMethod)
{
returnObject = dictClass.callObject(_methodName, classFactory.createClass(_classId), _record.TableId, _record.RecId);
}
else
{
returnObject = dictClass.callStatic(_methodName, _record.TableId, _record.RecId);
}
return returnObject;
}
public WorkflowTrackingName recordWorkflowTrackingName(Common _common)
{
WorkflowTrackingStatusTable workflowTrackingStatusTable;
WorkflowTrackingTable workflowTrackingTable;
boolean ret;
select firstonly1 Name
from workflowTrackingTable
join workflowTrackingStatusTable
order by WorkflowTrackingTable.CreatedDateTime desc
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingTable.TrackingContext == WorkflowTrackingContext::Step
&& workflowTrackingTable.TrackingType == WorkflowTrackingType::Creation
&& workflowTrackingStatusTable.ContextRecId == _common.RecId
&& workflowTrackingStatusTable.ContextTableId == _common.TableId;
return workflowTrackingTable.Name;
}
public WorkflowUser recordWorkflowAssignedUser(Common _common)
{
WorkflowTrackingStatusTable workflowTrackingStatusTable;
WorkflowTrackingTable workflowTrackingTable;
select firstonly RecId from workflowTrackingStatusTable
join User from workflowTrackingTable
order by WorkflowTrackingTable.CreatedDateTime desc
where workflowTrackingTable.WorkflowTrackingStatusTable == workflowTrackingStatusTable.RecId
&& workflowTrackingStatusTable.ContextRecId == _common.RecId
&& workflowTrackingStatusTable.ContextTableId == _common.TableId
&& workflowTrackingTable.TrackingContext == WorkflowTrackingContext::WorkItem;
return workflowTrackingTable.User;
}
public boolean isRecordWorkflowPendingItemAssignedToUser(Common _common, UserId _userId)
{
WorkflowWorkItemTable workflowWorkItemTableBuf;
select firstonly1 workflowWorkItemTableBuf
where workflowWorkItemTableBuf.UserId == _userId
&& workflowWorkItemTableBuf.RefRecId == _common.RecId
&& workflowWorkItemTableBuf.RefTableId == _common.TableId
&& workflowWorkItemTableBuf.Status == WorkflowWorkItemStatus::Pending;
return (workflowWorkItemTableBuf) ? true : false;
}
public void setRecordUserScope(Common _common, UserId _userId)
{
str scope = strFmt('CurrentUserScope-%1-%2', _common.TableId, _common.RecId);
container key = ['User'];
new SysGlobalObjectCache().insert(scope, key, [_userId]);
}
public UserId getRecordUserScope(Common _common)
{
container userContainer = new SysGlobalObjectCache().find(strFmt('CurrentUserScope-%1-%2', _common.TableId, _common.RecId), ['User']);
UserId userId = (userContainer != conNull()) ? conPeek(userContainer, 1) : curUserId();
return userId;
}
public void removeRecordUserScope(Common _common)
{
str scope = strFmt('CurrentUserScope-%1-%2', _common.TableId, _common.RecId);
container key = ['User'];
new SysGlobalObjectCache().remove(scope, key);
}
}
Comments
Post a Comment