Академический Документы
Профессиональный Документы
Культура Документы
How to create an auto lookup without writing code where Field 2 lookup is based on
Field 1 Value?
In order to achieve this create a relationship in the related table but make sure
Field 1 is the first relation in the relationship and Field 2 is the second
relation. This can be done by actually creating Field 2 relation before Field 1.
while (!System.String::IsNullOrEmpty(line))
{
line = reader.ReadLine();
text = line;
info(strfmt("%1", text));
}
reader.Close();
reader.Dispose();
}
iO = new CommaTextIo(filename,#IO_Read);
if (! iO || iO.status() != IO_Status::Ok)
{
throw error("@SYS19358");
}
while (iO.status() == IO_Status::Ok)
{
record = iO.read();
if (record)
{
if (first) // to exclude the header
{
first = false;
}
else
{
custAccount = conpeek(record, 1);
custname = conpeek(record, 2);
info(strfmt('%1--%2',custAccount,custname));
}
}
}
}
fileDialog = new Dialog("Select parking locations improt files for company " +
curext());
fileDialog.addText("Select parking locations improt files for company " +
curext());
sharedPath = fileDialog.addField(extendedTypeStr(FilenameOpen), "File Path");
fileDialog.run();
if (fileDialog.closedOk())
{
try
{
application = SysExcelApplication::construct();
workbooks = application.workbooks();
//TODO: Enter the excel file path
workbooks.open(sharedPath.value());
workbook = workbooks.item(1);
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
ttsBegin;
do
{
//First row should be column names
row = row + 1;
application.quit();
info("Records Import " + int2str(row));
ttsCommit;
}
catch
{
ttsAbort;
application.quit();
error("@SYS80663");
}
}
}
// >>> abdul @ 3rd June 2014 / Get New Auto Number Based On Company
public static str getNewPersonnelNumber()
{
int maxLenght = 4;
str tempEmployeeID;
str newNumber;
int newIndex;
str companyIdx;
HCMWorker localWorker;
str ret;
str 2 companyIdFilter;
return ret;
}
// >>> abdul @ 3rd June 2014 / Get New Auto Number Based On Company
PRMGenerateEarningAndDeductions::generateAllDedAndEarns(journalTransHeaderLocal);
}
ttscommit;
PRMJournalTransHeader_ds.executeQuery();
}
}
HcmWorker worker;
HcmEmployment employment;
#AviFiles
SysOperationProgress progressBar = new SysOperationProgress();
dimStorage.removeDimensionAttribute(DimensionAttribute::findByName(dimName).RecId);
}
return dimStorage.save();
}
ttsBegin;
while select worker
{
progressBar.setText(strfmt("Employee %1", worker.name()));
employment = HcmEmployment::getActiveEmploymentsByWorker(worker.RecId);
employment.selectForUpdate(true);
employment.validTimeStateUpdateMode(ValidTimeStateUpdate::Correction);
if(employment.DefaultDimension)
{
employment.DefaultDimension =
Global::setDefaultDimensionValue( employment.DefaultDimension, "Contract", "None");
employment.DefaultDimension =
Global::setDefaultDimensionValue( employment.DefaultDimension, "ContractType",
"None");
employment.update();
info(strFmt("%1, %2, Department Value: %3", worker.PersonnelNumber,
worker.name(),
getDefaultDimensionValue(employment.DefaultDimension,
"Department")));
}
}
ttsCommit;
}
USE AdventureWorks2012;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO
worksheetName = "@SYS135880";
sysExcelHelper = SysExcelHelper::construct();
sysExcelHelper.initialize();
worksheet = sysExcelHelper.addWorksheet(worksheetName);
worksheetHelper = SysExcelWorksheetHelper::construct(worksheet);
// Populate the header row with the appropriate field labels and format the
columns
worksheetHelper.addColumnFromTableField(#AccountNum, tablenum(CustTable),
fieldnum(CustTable, AccountNum));
worksheetHelper.addColumnFromTableField(#Currency, tablenum(CustTable),
fieldnum(CustTable, Currency));
worksheetHelper.addColumnFromTableField(#CustGroup, tablenum(CustTable),
fieldnum(CustTable, CustGroup));
worksheetHelper.addColumn(#BalanceMST, "Balance MST", Types::Real);
while select custTable
{
currentRow ++;
worksheetHelper.setCellValue(#AccountNum, currentRow,
custTable.AccountNum);
worksheetHelper.setCellValue(#Currency, currentRow, custTable.Currency);
worksheetHelper.setCellValue(#CustGroup, currentRow, custTable.CustGroup);
worksheetHelper.setCellValue(#BalanceMST, currentRow,
custTable.balanceMST());
}
if (currentRow > 1)
{
sumRow = currentRow + 2;
worksheetHelper.sumRange(worksheetHelper.getWorksheetRange(#BalanceMST, 2,
#BalanceMST, currentRow), #BalanceMST, sumRow);
// Generate the file using the current UTC date time (without the �:�
character)
// since it is not allowed for file names.
fileName = strfmt("%1%2%3", WinApi::getTempPath(),
strReplace(DateTimeUtil::toStr(DateTimeUtil::utcNow()), ":",""),
sysExcelHelper.getFileExtension());
sysExcelHelper.save(filename);
sysExcelHelper.launchExcel();
}
TreeNode _treeNode;
TreeNode projectNode;
TreeNodeIterator iterator;
int i, a;
// Initialising progress bar
progressBar.setCaption("Export To Excel in progress...");
progressBar.setAnimation(#AviTransfer);
_treeNode = infolog.projectRootNode();
_treeNode = _treeNode.AOTfirstChild();
//Traverse Class
static void FindTablesStartsWithXXX(Args _args)
{
UtilIdElements utilId;
;
while select utilId where utilid.recordType == UtilElementType::Table
&& utilId.name like 'MSTA*'
{
info(utilId.name);
}
pause;
}
DatabaseLog dblog;
ttsBegin;
dblog.logTable = tableNum(HcmWorker);
dblog.LogType = DatabaseLogType::Delete;
dblog.insert();
ttsCommit;
Dynamics AX Collections
How to create a list of records and iterate them?
AifAction aifAction;
List actionsList = new List(Types::Record);
ListEnumerator listEnum;
;
if(_actionsList)
{
listEnum = _actionsList.getEnumerator();
while(listEnum.moveNext())
{
aifAction = listEnum.current();
if( aifAction.WebMethodEnabled == NoYes::No &&
aifAction.WebSvcOutOfSync == NoYes::Yes &&
aifAction.ErrorState ==
AifServiceGenerationErrorState::WebServiceOutOfSyncError &&
aifAction.Intercompany == NoYes::No)
{
actionsList.addEnd(aifAction);
}
}
}
int realPart;
int decimalPart;
real hours;
str hoursStr;
str minStr;
int decimalLocation;
str finalMinutes;
;
try
{
hours = _hours;
hoursStr = num2str(hours, 0, 2, 1, 0);
decimalLocation = strfind(hoursStr, ".", 0, strlen(hoursStr));
hoursStr = substr(hoursStr, 0, decimalLocation);
hoursStr = trimString(hoursStr, ["."]);
minStr = num2str(hours, 0, 2, 1, 0);
minStr = substr(minStr, decimalLocation, strlen(minStr) -
strlen(hoursStr));
minStr = trimString(minStr, ["."]);
realPart = str2int(hoursStr);
decimalPart = str2int(minStr);
finalMinutes = hoursStr + ":" + (int2str(60 * decimalPart / 100) == "0" ?
"00" : int2str(60 * decimalPart / 100));
return finalMinutes;
}
catch
{
return num2str(_hours, 0, 2, 1, 0);
}
}
From <http://msdax.blogspot.com.au/2011/06/converting-real-number-to-time.html>
SELECT
db.name DBName,
tl.request_session_id,
wt.blocking_session_id,
OBJECT_NAME(p.OBJECT_ID) BlockedObjectName,
tl.resource_type,
h1.TEXT AS RequestingText,
h2.TEXT AS BlockingTest,
tl.request_mode
FROM sys.dm_tran_locks AS tl
INNER JOIN sys.databases db ON db.database_id =tl.resource_database_id
INNER JOIN sys.dm_os_waiting_tasks AS wt ON tl.lock_owner_address
=wt.resource_address
INNER JOIN sys.partitions AS p ON p.hobt_id =tl.resource_associated_entity_id
INNER JOIN sys.dm_exec_connections ec1 ON ec1.session_id =tl.request_session_id
INNER JOIN sys.dm_exec_connections ec2 ON ec2.session_id =wt.blocking_session_id
CROSS APPLY sys.dm_exec_sql_text(ec1.most_recent_sql_handle) AS h1
CROSS APPLY sys.dm_exec_sql_text(ec2.most_recent_sql_handle) AS h2
GO
KILL
From <http://blog.sqlauthority.com/2010/10/06/sql-server-quickest-way-to-identify-
blocking-query-and-resolution-dirty-solution/>
Lookups
How to create simple lookup?
Simple lookups can easily be created by adding a relation between the tables.
Step2: Call the lookup method from the overridden lookup method on the data source
field
public void lookup(FormControl _formControl, str _filterStr)
{
VendTable::lookupVendorByCurrency(_formControl, CustTable.Currency);
}
}
8. Write the NumberSeqFormHandler() in form methods node.
NumberSeqFormHandler numberSeqFormHandler()
{
if (!numberSeqFormHandler)
{
numberSeqFormHandler =
NumberSeqFormHandler::newForm(ProjParameters::numRefcarId
().NumberSequenceId,
element,
CarTable_DS,
fieldNum(CarTable, Car
Id)
);
}
return numberSeqFormHandler;
}
9.Write the close() on the form methods node.
void close()
{
if (numberSeqFormHandler)
{
numberSeqFormHandler.formMethodClose();
}
super();
}
10. Then final add the below methods on data source methods node
Create()
void create(boolean append = false,
boolean extern = false) // If created externally
{
element.numberSeqFormHandler().formMethodDataSourceCreatePre();
super(append);
if (!extern)
{
element.numberSeqFormHandler().formMethodDataSourceCreate(true);
}
}
Delete()
public void delete()
{
element.numberSeqFormHandler().formMethodDataSourceDelete();
super();
}
Write()
public void write()
{
super();
element.numberSeqFormHandler().formMethodDataSourceWrite();
}
Validate Write()
public boolean validateWrite()
{
boolean ret;
ret = super();
ret = element.numberSeqFormHandler().formMethodDataSourceValidateWrite(ret) &&
ret;
if (ret)
{
CarTable.validateWrite();
}
return ret;
}
Link Active()
public void linkActive()
{
;
element.numberSeqFormHandler().formMethodDataSourceLinkActive();
super();
}
Now our numberseqence is generated .
*** Set the field or Tabpage Allowedit property to No.
***Check the continues on wizard.