Dears,
I am using AX 2012 AIF to return Asset details , i can return all details except Department .
Can any one tell me how to return Department .
if you checked AxdFixedAsset Query , you can find there is relation between AssetTable and OMOperatingUnitView
This My code in C# to get Asset details
public HttpResponseMessage get()
{
try
{
AssetFixedAssetServiceClient _client = new AssetReference.AssetFixedAssetServiceClient();
AssetReference.CallContext _callContext = new AssetReference.CallContext();
_callContext.Company = "XX";
AssetReference.QueryCriteria qc = new AssetReference.QueryCriteria();
qc.CriteriaElement = new AssetReference.CriteriaElement[1];
qc.CriteriaElement[0] = new AssetReference.CriteriaElement();
qc.CriteriaElement[0].DataSourceName = "AssetTable";
qc.CriteriaElement[0].FieldName = "AssetID";
qc.CriteriaElement[0].Operator = AssetReference.Operator.Equal;
qc.CriteriaElement[0].Value1 = "XXXX";
AxdFixedAsset _asset = _client.find(_callContext, qc);
IEnumerator enumerator;
enumerator = _asset.AssetTable.GetEnumerator();
int result = 0;
//Class conatain Asset ID & Name
Models.AssetList FAS = new Models.AssetList();
List<Models.AssetList> list = new List<Models.AssetList>();
while (enumerator.MoveNext())
{
result++;
AxdEntity_AssetTable _asetEnt = (AxdEntity_AssetTable)enumerator.Current;
FAS = new Models.AssetList();
FAS.AsId1 = _asetEnt.AssetId;
//I need to Return Department
FAS.ASName1 = "I need to Return Department "
list.Add(FAS);
}
return Request.CreateResponse(HttpStatusCode.Created, list);
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
}
}