My requirement is to auto populate newly created asset to custom form. And if any updates are done in asset management it should also update in custom form.
Add status enum field in :
Path: Asset
management > Setup > Assets > Lifecycle states
Path: Asset
management > Setup > Asset types > Asset types
Asset should be available in custom form if Equipment integration is set to yes.
Create a custom table and form:
[ExtensionOf(formStr(EntAssetObjectTableCreate))]
internal final class DaxEntAssetObjectTableCreateForm_Extension
{
public void closeOk()
{
DaxEquipmentTable daxEquipmentTable;
next closeOk();
FormDataSource datasource = this.dataSource();
EntAssetObjectTable tntAssetObjectTable = datasource.cursor();
EntAssetObjectType entAssetObjectType;
EntAssetObjectLifecycleState entAssetObjectLifecycleState;
select entAssetObjectType
where entAssetObjectType.RecId == tntAssetObjectTable.ObjectType;
select entAssetObjectLifecycleState
where entAssetObjectLifecycleState.RecId == tntAssetObjectTable.ObjectLifecycleState;
if(entAssetObjectType.EquipmentIntegration == NoYes::Yes)
{
daxEquipmentTable.AssetId = tntAssetObjectTable.ObjectID;
daxEquipmentTable.EquipmentIDPrefix = entAssetObjectType.EquipmentIDPrefix;
daxEquipmentTable.EquipmentType = entAssetObjectType.EquipmentType;
daxEquipmentTable.Equipmentstatus = entAssetObjectLifecycleState.Equipmentstatus;
daxEquipmentTable.insert();
}
}
}
When an EAM Asset lifecycle is updated, then
also update the equivalent TM equipment record’s status
Path : Asset management > all assests > lifecycle state > update assate state
Path: Asset management > Setup > Assets > Lifecycle states
The Equipment status for scrapped is RDY. It should update in custom form.
Code:
[ExtensionOf(formStr(EntAssetLifecycleStateUpdate))]
internal final class DaxEntAssetlifecycleStatusupdate_Extension
{
public void closeOk()
{
EntAssetLifecycleStateMap newLifecycleState;
DaxEquipmentTable daxEquipmentTable;
FormRun formRun;
EntAssetObjectTable entAssetObjectTable;
EntAssetTmpLifecycleStateUpdate entAssetTmpLifecycleStateUpdate;
EntAssetObjectLifecycleState entAssetObjectLifecycleState;
Common table= this.dataSource().cursor();
entAssetTmpLifecycleStateUpdate = table;
formRun = this.dataSource().formRun();
entAssetObjectTable = formRun.args().record();
next closeOk();
select forupdate daxEquipmentTable
where daxEquipmentTable.AssetId == entAssetObjectTable.ObjectID;
select entAssetObjectLifecycleState
where entAssetObjectLifecycleState.ObjectLifecycleStateId == entAssetTmpLifecycleStateUpdate.LifecycleStateId;
if(daxEquipmentTable)
{
ttsbegin;
daxEquipmentTable.Equipmentstatus = entAssetObjectLifecycleState.Equipmentstatus;
daxEquipmentTable.update();
ttscommit;
}
}
}
Go to the EAM Asset and select
Install asset at location
Check the selected Functional location life cycle state.
Based on the life cycle state , the equipment status should update in custom form. Same as above.
So the lifecycle status is Active, For Active we have selected "Out of service" status in lifecycle state. this Out of service should be updated in Custom form Equipment status field.
Code :
[ExtensionOf(formStr(EntAssetFunctionalLocationObjectInstall))]
internal final class DaxEntAssetfunctionalLocationObjectInstall_Extension
{
public void closeOk()
{
EntAssetFunctionalLocation entAssetFunctionalLocation;
EntAssetObjectLifecycleState entAssetObjectLifecycleState;
DaxEquipmentTable daxEquipmentTable;
str functionalid;
FormReferenceGroupControl control = this.design().controlName(formControlStr(EntAssetFunctionalLocationObjectInstall, FunctionalLocation)) as FormReferenceGroupControl;
FormStringControl subStringControl = control.controlNum(1) as FormStringControl;
FormStringControl objectId = this.design().controlName(formControlStr(EntAssetFunctionalLocationObjectInstall, ObjectID)) as FormStringControl;
next closeOk();
functionalid = subStringControl.text();
select entAssetFunctionalLocation
where entAssetFunctionalLocation.FunctionalLocationId == functionalid;
select entAssetObjectLifecycleState
where entAssetObjectLifecycleState.RecId == entAssetFunctionalLocation.FunctionalLocationType;
select forupdate daxEquipmentTable
where daxEquipmentTable.AssetId == objectId.text();
if(daxEquipmentTable)
{
ttsbegin;
daxEquipmentTable.Equipmentstatus = entAssetObjectLifecycleState.Equipmentstatus;
daxEquipmentTable.update();
ttscommit;
}
}
}
No comments:
Post a Comment