Container parameters in custom service

Hi Team,

I am trying to return the Inventory Onhand to the List of Items w.r.t Warehouse and Config. I have made all the 3 parameters as Containers and and inserting into temporary table and returning the temporary table.When i am testing through Job it is working Fine, However when i am trying to add To Operation Method for the respective Service i am not getting the method which i have created to add under operations. Can you please let me know what would be the root cause. Below is the code which i have written in the class.

[AifDocumentCreateAttribute,SysEntryPointAttribute(true)]

public InventCheck getItemOnHand(container _ItemId, container warehouse,container configid)

{

InventOnhand inventonhand;

InventDim inventdim;

InventDimParm inventdimparm;

InventCheck inc;

int i;

InventQty inventqty;

;

for(i=1; i<= conLen(_ItemId); i++)

{

inventdim.InventSiteId=‘BG’;

inventdim.InventLocationId=conPeek(warehouse,i);

inventdim.configId=conPeek(configid,i);

inventdimparm.initFromInventDim(inventdim);

inventonhand = InventOnhand::newParameters(conPeek(_ItemId,i),inventdim,inventdimparm);

inventqty = inventonhand.availPhysical();

inc.ItemId=conPeek(_ItemId,i);

inc.Onhand=inventqty;

inc.insert();

}

return inc;

}

The issue is with the parameter type, parameter type container /blob/Any type are not allowed.

Hi Kranthi,

Thanks for the quick help. Can you please help me in knowing which type i need to use to crack the challenge.

1 Like

you can use list, check below example

community.dynamics.com/…/custom-aif-service-in-dynamics-ax-2012-r3-from-scratch

Hi Kunal,

Thanks a lot for sharing the blog. I was going through the blog but in our case i need to List of Items, Warehouses and Configs as Parameters and return Item Id and Its On Hand. I this case how we need to modify it

You can use collection class like List

you can use list type of string for all 2 parameters.
but you can not return directly the table record , check below thread discussion

stackoverflow.com/…/aif-service-operation-that-returns-a-table-object

Hi Kranthi,

In our case we have three parameters as List. So could you please help me how the list of Data would get initialized when i am using collection class as input parameter

Not sure what does that mean? can you explain in detail?

1 Like

Hi Kranthi,

When i am passing input parameter as collection class, how the data would get assigned and how can we compare the data if we need to select the data from table based on the class values.

Just like the container, you can loop through the list values using list ListEnumerator.
msdn.microsoft.com/…/listenumerator.aspx