Hello experts,
I am trying to make it such that when a user presses the New button in a form, a new case will get created in MyTable and the default Case table in AX (I assume it would be "CaseDetailBase"), with a default value inserted into the table without needing the user to input any values.
I could access the detail view of a particular case I created, however, with limitations, and I have no idea how to create/ parse/ initiate a default value of a case category for it. How do we go about making it works?
A case created manually by user in All cases (can be accessed inside Common menu) via the New button has no greyed out input fields such as this screenshot here:
However, the case which I created/ posted via X++ has greyed-out inputs fields such as not being able to input values into Service level agreement, Case resolution, Billing project, Follow-up fields, etc. The screenshot is located below here:
The code which I wrote to create/posts the case is located below:
The code below is as far as I could get.
If I do lack any information at all, please let me know and I will provide it.
Thanks in advance.
private void insertRecIntoTables(boolean _newRecord = false)
{
CaseDetailForm caseDetailForm = new CaseDetailForm();
CaseDetailBase caseDetailBase; //Main table for managing case in AX
ttsbegin;
if (_newRecord) //executes if the _newRecord boolean is true
{
//get the next number sequence from CaseDetailForm class by using numRefCaseId's static method
NumberSeq numberSeq = NumberSeq::newGetNum(CaseDetailForm::numRefCaseId());
MyTable.CaseId = numberSeq.num();
MyTable.CaseStatus = CaseStatus::Planned;
//Make a manual insert of a new record into MyTable
MyTable.insert();
}
select forupdate caseDetailBase
where caseDetailBase.CaseId == MyTable.CaseId;
//Check to see if the record exists. If not, create one
if (!caseDetailBase)
{
caseDetailBase.CaseId = MyTable.CaseId; //Pass CaseId
//The fields below are hard-coded because these are considered as the default values
if (new DictEnum(enumNum(CaseCategoryType)).symbol2Value("Services"))
{
//Case creation default values
info("A value of Service exists inside CaseCategoryType enum");
//I want to set the default category type as a "Service"
//However, the code below does not work, so I commented it out...first
//caseDetailForm.parmCategoryType(CaseCategoryType::Service);
//Hard-coded CategoryRecId as 11290924143, which is type "Service"
//Which is not what I want...by hard-coding it this way
caseDetailBase.CategoryRecId = 11290924143;
caseDetailBase.Status = MyTable.CaseStatus;
}
//If "Service" string enum does not exist, force a creation of one
else
{
//I need to find out how to create an enum value in X++, which is an Int64 datatype!
}
caseDetailBase.insert(); //Force an insert
}
//else if a record exists, just update the fields in instead of creating one in CaseDetailBase
//CaseDetailBase is an AX default system table which could be found using in AOT CaseDetail form
else
{
caseDetailBase.Status = MyTable.CaseStatus; //Pass CaseStatus
caseDetailBase.Memo = MyTable.Memo; //Pass memo
caseDetailBase.update();
}
ttscommit;
MyTable_ds.research(true); //refresh the form's grid
}
*This post is locked for comments
I have the same question (0)

Report
All responses (
Answers (