Reputation: 2620
In InventJournalName table there is JournalNameId column and JournalType.
Using:
InventJournalNameId inventJournalName;
inventJournalName = InventJournalName::standardJournalName(InventJournalType::Movement);
I am indeed able to get a JournalNameId of type Movement from the InventJournalName table. To be more concise, the first one.
With the debugger I got to this point :
public static InventParameters find(boolean _forupdate = false)
{
InventParameters parameter;
if (_forupdate)
{
parameter.selectForUpdate(_forupdate);
}
select firstonly parameter
index Key
where parameter.Key == 0;
if (!parameter && !parameter.isTmp())
{
Company::createParameter(parameter);
PrintMgmt::createDefaultData(PrintMgmtHierarchyType::Invent);
}
return parameter;
}
To be honest, I can't really understand what's the role of the InventParameters table.
It's clear that:
select firstonly parameter
index Key
where parameter.Key == 0;
will return what I need but what's the mechanism behind the scenes?
Is there any difference between the above way and:
select firstOnly inventJournalName
where inventJournalName.JournalType ==
InventJournalType::Movement;
Upvotes: 1
Views: 123
Reputation: 1496
The reason you have a parameter is because you should be able to define a standard journal name regardless of how many journal names you have in the InventJournalName
table.
You can have multiple journal names in that table for the same journal type, as long as they don't have the same name.
If you have 2 names of type movement this code
select firstOnly inventJournalName
where inventJournalName.JournalType ==
InventJournalType::Movement;
would basically return a random record (if there is no order by there is no guarantee which will be first).
This on the other hand
select firstonly parameter
index Key
where parameter.Key == 0;
Will return what's in your parameter table and is deterministic.
If you were wondering why the where parameter.key == 0
is for. That's because of how AX's caching mechanism works. All parameter tables are set to entiretablecache=yes
but records are only retrieved from cache if the select is on the primary key.
Upvotes: 3