How can I, with X++, create a sales order from a sales quotation in AX 4.0? I've searched and found the same answer several places, however it seems to be specific to newer versions of AX.
This is what I've found here: https://community.dynamics.com/ax/b/mafsarkhan/archive/2014/04/14/create-sales-order-from-sales-quotation
static void createSalesOrderFromQuote(Args _args)
{
SalesQuotationTable salesQuotationTable = SalesQuotationTable::find("");
SalesQuotationEditLinesForm editLinesForm;
ParmId parmId;
editLinesForm = SalesQuotationEditLinesForm::construct(DocumentStatus::Confirmation);
parmId = editLinesForm.parmId();
editLinesForm.initParmSalesQuotationTable(salesQuotationTable);
editLinesForm.parmTransDate(systemDateGet());
editLinesForm.prePromptInit();
editLinesForm.initParameters(NoYes::No, NoYes::No, NoYes::No, NoYes::No, NoYes::No, '', NoYes::No);
editLinesForm.run();
}
The line editLinesForm.prePromptInit(); wont compile and I guess that is due to only being available in newer versions. I can comment it out and the code will compile and run. However, even though I've added the ID of the SalesQuotationTable like this: ... ::find("123456") It's seems the code converts ALL my quotations to salesorders, however I've yet to confirm this as I've been forced to kill the process to start working again.
I think you may comment out the call to editLinesForm.prePromptInit() from your method.
In order to not post all quotations into sales orders I would try to reproduce the main() method of the SalesQuotationEditLinesForm class in your system, omitting the logic related to datasource.
If I refer to my system I think your code might be missing:
editLinesForm.getLast();
editLinesForm.parmId(parmId);
before calling editLinesForm.run()
Related
I have an enumerand of around 150 entries, which I need to get into IBM Rhapsody.
Doing this by hand is clearly lengthy and error prone. I have google extensively but found only things that tell me how to edit the generated code -- not go the other way.
The question is: How is this done? And if there is no way -- please someone post that as an answer.
David,
I would jump into the Java API (plugin subsystem) and do it that way. If you haven't learned how to use the API, there is a bit of a learning curve. There are two ways to go about it: Implement a Java (or your favorite JVM language--I use Scala) app that realizes the Rhapsody Plugin framework and then you choose to package it up and deploy it so that it gets loaded when you load your model, or, if it is a one off job, do everything up to the point of packaging it up and then run it from within your IDE and you are done. If you are comfortable with Scala, I can post some code.
So what I did in the end was I edited the relevant .sbs file, used a small python program to generate the items I required, and then update the length of the array accordingly.
all_the_literals = ["enum_name = 0x4e", enum_name2 = 0xF2", ... ,]
for field1, waste, field1_value in map(lambda x: x.split(" "),
all_the_literals):
literal_string = f""" {{ IEnumerationLiteral
- _id = GUID {uuid.uuid4()};
- _name = \"{field1}\";
- codeUpdateCGTime = 5.16.2022::19:24:18;
- _modifiedTimeWeak = 5.16.2022::19:24:18;
- _value = \"{field1_value}\";
}}"""
print(literal_string)
Note the above "code" snippet purely prints the items, which you then copy-paste into the relevant field in the sbs file. YMMV -- this was the correct format for an enum in Rhapsody (and note how I fudged the update time, but it worked successfully, so you'll need to do the same if you use this answer).
Also note it's probably better to use bauhaus9's answer, but I definitely didn't have time for it.
I have a field in my acore_characters table named 'rank' with a tinyint which ranges from 0 to 3 inclusive, based on player's progression. I need to read that value at both login and at certain specific circumstances.
I wrote the following PreparedStatement: "SELECT rank FROM acore_characters WHERE guid = ?" and then the code which is supposed to read that value:
uint16 GetCharactersRank(uint64 guid) {
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(mystatement);
stmt->setUInt32(0, GetGUID());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result) {
[...truncated]
and then fetching the result and so on, but then I get a code C8361 when compiling because 'GetGUID':identifier not found in Player.cpp file...what goes wrong? The other GetGUID calls throughout the file dont give this result. I'm not very fond of c++, any help is very appreciated.
It's not recommended to directly patch the core to add customisations to it. Instead, use modules.
An example can be found here: Is it possible to turn a core patch into a module for AzerothCore?
You can have a look and copy the skeleton-module and start modifying it to create your own.
In your case, you probably want to use the OnLogin player hook.
I'm posting to a general journal in ax 2012. I'm able to create the journal and enter most line information from x++ code. Now i'm having an issue with some vendor numbers.
When I use this code most of the time it works. But there are a few vendor numbers that are not able to be found from this table and of course throws an error. Weird thing is if I actually go into ax and type in the vendor number it does accept it because it has been setup in the system but by this code it is not working (for some).
Just wondering if there is something wrong with how the vendor number is setup, properly not linked with something, or if there is another way to properly set this parameter.
It looks like parmledgerDimension uses a RecId for vendors and only pulls it from DimensionAttributeValueCombination.
Any ideas?
DimensionAttributeValueCombination davc;
firstonly RecId from davc where davc.DisplayValue == account; //could be 010-000001
journalTrans.parmLedgerDimension(davc.RecId);
Try using
DimensionStorage::getDynamicAccount(account, LedgerJournalACType::Vend);
https://msdn.microsoft.com/en-us/library/dimensionstorage.getdynamicaccount.aspx
Edit: the first line I posted was to get the default dimension. I'll leave it in case you need it
LedgerJournalEngine::getAccountDefaultDimension(account, curext(), LedgerJournalACType::Vend);
https://msdn.microsoft.com/en-us/library/ledgerjournalengine.getaccountdefaultdimension.aspx
I have been trying to post packing slip from code. I have tried several ways but unfortunately without success.
My code is below:
purchTable = PurchTable::find('PO0012555');
purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
purchformLetter.getLast();
purchFormLetter.transDate(transDate);
numberSeq = NumberSeq::newGetNum(PurchParameters::numRefPurchPackingSlipId()).num();
purchFormLetter.update(purchTable,
"14",// numberSeq, //this is coming out blank
transDate,
PurchUpDate::All,
AccountOrder::None,
false,
false);
When I tried to execute, I was getting this error:
Inventory is closed for physical and financial transactions until
Do you have any idea? Any help will be appreciated.
Thanks
My guess: your transDate variable does not have a valid date.
Using the cross reference you see the error only occurs in the checkOpen method of the table InventClosing.
Feel free to add a breakpoint here!
The method will fail if called with a blank transaction date.
Are you posting to a closed period? What is transdate? Check (General Ledger>Setup>Periods>Periods)
Thanks to masters who tried to help me but I figured out my problem. There is no problem about my code or anywhere.
We are working on this project with another consulting company. Somehow, one of developer who works other company remarked (commented) transdate line at PurchFormLetter class without any information.
So, when I tried to set transdate value at "purchFormLetter.transDate(transDate)" line, PurchFormLetter could not able to set the value cause of remarked line.
I uncommented the line and the code worked like a charm.
I'm working in some old code which was originally designed for handling two different kinds of files. I was recently tasked with adding a new kind of file to this code. Most of my problems were solved by filling out an extensive XML file with a new entry that handled everything from what lists were named to how the file is written in plural lower case. But this ended up being insufficient, as there were maybe 50 different places in 24 different code files where I had to update hardcoded switch-statements that only branched for the original two file types.
Unfortunately there is no consistency in this; there are methods which operate half from the XML file, and half off of hardcode. Some of the files which look like they would operate off of the XML file don't, and some that I would expect that I'd need to update the hardcode don't need it. So the only way to find the majority of these is to run through testing the whole system when only part of it is operational, finding that one step to fix (when I'm lucky that error logging actually tells me what is going on), and then running the whole thing again. This wastes time testing the parts of the code which are already confirmed to work, time better spent testing the new parts I have to add on top of it all.
It's a hassle and a half, and to my luck I can expect that I will have to add yet another new kind of file in the near future.
Are there any solutions out there which can aid in this kind of endeavour? Something which I can input some parameters of current features, document what points in a whole code project actually need to be updated, and run something nice the next time I need to add a new feature to the code. It needn't even be fully automated, something that'll help me navigate straight to the specific points in everything and maybe even record what kind of parameters need to be loaded.
Doubt it matters specifically, but the code is comprised of ASP.NET pages, some ASP.NET controls, hundreds of C# code files, and a handful of additional XML files. It's all currently in a couple big Visual Studio 2008 projects.
Not exactly what you are describing, but if you can introduce a seam into the code and lay down some interfaces you can break out and mock, a suite of unit/integration tests would go a long way to helping you modify old code you may not fully understand well.
I completely agree with the comment about using Michael Feathers' book to learn how to wedge new tests into legacy code. I'd also strongly recommend Refactoring, by Martin Fowler. What it sounds like you need to do for your code is to implement the "Replace conditionals with polymorphism" refactoring.
I imagine your code today looks somewhat like this:
if (filetype == 23)
{
type23parser.parse(file);
}
else if (filetype == 69)
{
filestore = type69reader.read(file);
File newfile = convertFSto23(filestore);
type23parser.parse(newfile);
}
What you want to do is to abstract away all the "if (type == foo)" kinds of logic into strategy patterns that are created in a factory.
class FileRules : pReader(NULL), pParser(NULL)
{
private:
FileReaderRules *pReader;
FileParserRules *pParser;
public:
void read(File* inFile) {pReader->read(inFile);};
void parse(File* inFile) {pParser->parse(inFile);};
};
class FileRulesFactory
{
FileRules* GetRules(int inputFiletype, int parserType)
{
switch (inputFiletype)
{
case 23:
pReader = new ASCIIReader;
break;
case 69:
pReader = new EBCDICReader;
break;
}
switch (parserType)
... etc...
then your main line of code looks like this:
FileRules* rules = FileRulesFactory.GetRules(filetype, parsertype);
rules.read(file);
rules.parse(file);
Pull off this refactoring, and adding a new set of file types, parsers, readers, etc., becomes as simple as writing one exclusive to your new type.
Of course, go read the book. I vastly oversimplified it here, and probably got stuff wrong, but you should get the general idea of how to approach it from this. I can also recommend another book, "Head First Design Patterns", which has a great section on the Factory patterns (if you like those "Head First" kinds of books.)