30.12.2010, 00:12
|
#1
|
Участник
|
Dynamics AX Sustained Engineering: Fields modifiedDateTime and modifiedBy on Table InventSum
Источник: http://blogs.technet.com/b/dynamicsa...inventsum.aspx
==============
Problem:
Fields "modifiedDateTime" and "modifiedBy" on Table InventSum are not updated correct in inventory journals.
Resolution:
The following code changes will update the modifiedDateTime and modifiedBy fields on the InventSum table when posting Inventory Journals.
1.\ Classes\InventUpdateOnHand\sqlUpdateInventSumStrSQLServer
1.1Add comments on added SQL str in the beginning of this method
/* This method will build following statement in a str:
InventSum.LastUpdDateExpected= CASE WHEN InventSum.LastUpdDateExpected > InventSumDelta.MAX_LastUpdDateExpected
THEN InventSum.LastUpdDateExpected
ELSE InventSumDelta.MAX_LastUpdDateExpected
END,
//New added begin
InventSum.ModifiedDateTime = dateadd(ms, -datepart(ms,getutcdate()), getutcdate()),
InventSum.ModifiedBy= currentUserId,
//New added end
1.2Variable definition
Added code is listed as below.
str 256tmpFieldNameModifiedDate= new SysDictField(tablenum(InventSum),fieldnum(InventSum, ModifiedDateTime)).name(DbBackend::Sql,0,FieldNameGenerationMode::FieldList);
str 256tmpFieldNameModifiedBy= new SysDictField(tablenum(InventSum),fieldnum(InventSum, ModifiedBy)).name(DbBackend::Sql,0,FieldNameGenerationMode::FieldList);
userIdcurrentUserId = curuserid();
1.3Added SQL clause
//InventSum.LastUpdDateExpected = CASE WHEN InventSum.LastUpdDateExpected > InventSumDelta.MAX_LastUpdDateExpected
//THEN InventSum.LastUpdDateExpected
//ELSE InventSumDelta.MAX_LastUpdDateExpected
//END,
pct2 += ', ' + inventSumName + '.' + tmpFieldNameUpdExp + ' = CASE WHEN '+ inventSumName + '.' + tmpFieldNameUpdExp + ' > ' + inventSumDeltaName + '.' + maxPrefix + tmpFieldNameUpdExp;
pct2 += ' THEN '+ inventSumName + '.' + tmpFieldNameUpdExp + ' ELSE ' + inventSumDeltaName + '.' + maxPrefix + tmpFieldNameUpdExp + ' END ';
// New added begin
//InventSum.ModifiedDateTime = dateadd(ms, -datepart(ms,getutcdate()), getutcdate()),
pct2 += ', '+ inventSumName + '.' + tmpFieldNameModifiedDate + ' = dateadd(ms, -datepart(ms,getutcdate()), getutcdate()) ';
// InventSum.ModifiedBy = currentUserId,
if (tmpFieldNameModifiedBy) // table property ModifiedBy might not be enabled
{
pct2 += ', ' + inventSumName + '.' + tmpFieldNameModifiedBy + ' = ' + '\'\'' + currentUserId + '\'\'';
}
// New added end
2.Enable table property ModifiedDateTime and CreateRecIdIndex:
“\DataDictionary\Tables\InventSum\TableProperty”
Save table “\DataDictionary\Tables\InventSum”. Synchronize DataDictionary.
Источник: http://blogs.technet.com/b/dynamicsa...inventsum.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
|
|