public void registerTransaction()
{
InventTrans inventTrans;
InventDim inventDim;
InventTransWMS_Register inventTransWMS_register;
TmpInventTransWMS tmpInventTransWMS;
inventTrans = InventTrans::findTransId(salesLine.InventTransId);
if(inventTrans && inventTrans.StatusReceipt != StatusReceipt::Registered)
{
inventDim = inventTrans.inventDim();
tmpInventTransWMS.clear();
tmpInventTransWMS.initFromInventTrans(inventTrans);
tmpInventTransWMS.InventQty = inventTrans.Qty;
tmpInventTransWMS.InventDimId = inventDim.inventDimId;
tmpInventTransWMS.insert();
inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);
inventTransWMS_Register.createFromInventTrans(inventTrans, inventDim);
inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,
inventTrans, inventDim);
inventTransWMS_register.updateInvent(inventTrans);
}
}
Thursday, August 30, 2018
Register a sales order line or any other inventory transaction
Create new HCMWorker (Worker)
Example of an x++ method for creating new Worker in AX2012 based on parameters as first name, last name, start date and we need preconfigured default position for hiring a new worker. This piece of code also updates existing worker.
protected void createWorker(){
DirPersonName dirPersonName;
DirPerson dirPerson;
HcmWorker newHcmWorker;
CompanyInfo companyInfo;
HcmPosition hcmPosition;
HcmPositionDuration hcmPositionDuration;
HcmPositionDetail hcmPositionDetail,
fromHcmPositionDetail;
FirstName firstName;
LastName lastName;
ValidFromDateTime startDate;
ValidToDateTime endDate;
HcmPersonnelNumberId workerId;
workerId = 'Worker-01';
firstName = 'Worker First name';
firstName = 'Worker Last name';
startDate = DateTimeUtil::utcNow();
endDate = DateTimeUtil::applyTimeZoneOffset(DateTimeUtil::maxValue(), DateTimeUtil::getUserPreferredTimeZone());
ttsBegin;
dirPersonName.FirstName = firstName;
dirPersonName.LastName = lastName;
companyInfo = CompanyInfo::find();
newHcmWorker = HcmWorker::findByPersonnelNumber(workerId, true);
//Hire new Worker if Worker not found
if(!newHcmWorker)
{
fromHcmPositionDetail = HcmPositionDetail::findByPosition(11111111);// default position details to creating a new worker
// Create a position with position details and duration
hcmPosition.clear();
hcmPosition.initValue();
hcmPosition.PositionId = NumberSeq::newGetNum(NumberSeqReference::findReference(extendedTypeNum(HcmPositionId)), true).num();
hcmPosition.insert();
buf2Buf(fromHcmPositionDetail, hcmPositionDetail);
hcmPositionDetail.Position = hcmPosition.RecId;
hcmPositionDetail.ValidFrom = startDate;
hcmPositionDetail.ValidTo = DateTimeUtil::maxValue();
hcmPositionDetail.insert();
hcmPositionDuration.initValue();
hcmPositionDuration.Position = hcmPosition.RecId;
hcmPositionDuration.ValidFrom = startDate;
hcmPositionDuration.ValidTo = DateTimeUtil::maxValue();
hcmPositionDuration.insert();
newHcmWorker = HcmWorker::find(HcmWorkerTransition::newHireHcmWorker( dirPersonName,
workerId,
hcmPosition.RecId,
startDate,
endDate,
startDate,
endDate,
companyInfo.RecId,
HcmEmploymentType::Employee));
}
// Updating an existing worker
else
{
// Updating an existing worker DirPersonName
if (newHcmWorker)
{
dirPersonName = DirPersonName::find(newHcmWorker.Person);
if(dirPersonName.FirstName != firstName || dirPersonName.LastName != lastName)
{
dirPersonName.clear();
dirPersonName.FirstName = firstName;
dirPersonName.LastName = lastName;
dirPerson.initValue();
dirPerson.updateName(dirPersonName);
if (dirPerson.validateWrite())
{
dirPerson.insert();
dirPersonName.Person = dirPerson.RecId;
dirPersonName.ValidFrom = DateTimeUtil::minValue();
dirPersonName.ValidTo = DateTimeUtil::maxValue();
if (dirPersonName.validateWrite())
{
dirPersonName.insert();
}
}
newHcmWorker.Person = dirPerson.RecId;
if (newHcmWorker.validateWrite())
{
newHcmWorker.update();
}
}
//Update worker assignment
HcmWorkerTransition::newUpdateHcmEmployment(
HcmEmployment::findByWorkerLegalEntity(newHcmWorker.RecId, companyInfo.RecId),
startDate,
endDate);
}
}
ttsCommit;
}
Thursday, May 3, 2018
How to uninstall model from UAT/PROD environment
Recently I need to deleted model, which was installed on the UAT/PROD environment via LCS. So I do not have access to the file system. And all the controls are carried out with the help of the LCS. And there was a need to remove the model from the environment via the LCS.
Please find below the instructions for uninstalling a model in UAT/PROD.
If the model is extension model:
1. Delete all the components from a model and create a deployable package out of it.
2. Create a text file called “ModuleToRemove.txt” and put it into the AOSService\Scripts folder
3. In the text file, put in the name of the module you want to remove, for example – “MyModule”
4. Zip up the package and upload into the asset library
5. Apply the package in a sandbox
If the model is an overlayered model:
1. Remove it (over layered code) from DEV environment in Visual Studio
2. Build the module (say if you have overlayered Application suite, build the Application suite module again after over-layering is removed)
3. Create a deployable package of the module that has over layering removed (say Application suite)
4. Follow the instruction to create a text file in the AOSService\Scripts folder and put Application suite in it.
5. Deploy the package as usual
6. During the deployment, it will wipe the whole Application suite module (with your overlaying) and reapply the new Application suite module in the package (without overlaying)
It should be noted that model directories will remain in the file system, but the models will be removed from the list of models available in the Visual Studio.
Source: Answer from Microsoft Support Engineer
Please find below the instructions for uninstalling a model in UAT/PROD.
If the model is extension model:
1. Delete all the components from a model and create a deployable package out of it.
2. Create a text file called “ModuleToRemove.txt” and put it into the AOSService\Scripts folder
3. In the text file, put in the name of the module you want to remove, for example – “MyModule”
4. Zip up the package and upload into the asset library
5. Apply the package in a sandbox
If the model is an overlayered model:
1. Remove it (over layered code) from DEV environment in Visual Studio
2. Build the module (say if you have overlayered Application suite, build the Application suite module again after over-layering is removed)
3. Create a deployable package of the module that has over layering removed (say Application suite)
4. Follow the instruction to create a text file in the AOSService\Scripts folder and put Application suite in it.
5. Deploy the package as usual
6. During the deployment, it will wipe the whole Application suite module (with your overlaying) and reapply the new Application suite module in the package (without overlaying)
It should be noted that model directories will remain in the file system, but the models will be removed from the list of models available in the Visual Studio.
Source: Answer from Microsoft Support Engineer
Subscribe to:
Posts (Atom)
-
In d365 for finance and operation a new static method was added to the global class – Global::runAsync() Let’s create some asynchron...
-
NOTE: Whenever I write a Google query to find information about the new AX system, I mention the bad word of those who create the name for ...
-
In the previous article, I created two services and checked their work. Let's upgrade the work of our first service in such a way th...