[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.axapta.programming

Com Connector/C#: How do I access a Base Enum?

EricR

12/21/2005 3:15:00 PM

I'm trying to create an InventTable record and need to know how to
reference the ItemType base enum to fill in the type field.

Anyone know how to do this?

The basic flow of the code is:
string axTableName = "InventTable";


// some prep code


IAxaptaRecord record =
(IAxaptaRecord)_Axapta.CreateRecord(axTableName);


record.InitValue();
record.set_field("ItemGroupId", newPart.ItemGroup);
record.set_field("Dimension[2]", newPart.ItemGroup);
record.set_field("DimGroupId", newPart.DimGroup);
record.set_field("modelGroupId", newPart.InventModelGroup);

record.set_field("itemName", newPart.Description);
record.set_field("itemId", newPart.PartNumber);
record.set_field("NameAlias", newPart.PartNumber);
record.set_field("CostGroupId", newPart.CostGroup);
record.set_field("PrimaryVendorId", newPart.Vendor);

// The set_fields below are the problem, I was just guessing
// here but this does not work.
if( newPart.ItemType == "Item" )
record.set_field("ItemType", "ItemType::Item");
else
record.set_field("ItemType", "ItemType::BOM");


I was looking for a way to create the ItemType base enum but have not
found a way to do it yet.


Thanks all..

3 Answers

Luegisdorf

12/22/2005 9:40:00 AM

0

Hi Eric

You have to compare with 'newPart.ItemType == 0' because BaseEnums are
stored as integer so you can also use integers to compare. But if you are not
sure if the zero is related to 'item' you can use the DictEnum-Object to
check (or get the right assigned integer to the symbol like 'Item').

If you don't know how to use the DictEnum Object, please ask again.

Hope this helps you.

Best regards
Patrick

"EricR" wrote:

> I'm trying to create an InventTable record and need to know how to
> reference the ItemType base enum to fill in the type field.
>
> Anyone know how to do this?
>
> The basic flow of the code is:
> string axTableName = "InventTable";
>
>
> // some prep code
>
>
> IAxaptaRecord record =
> (IAxaptaRecord)_Axapta.CreateRecord(axTableName);
>
>
> record.InitValue();
> record.set_field("ItemGroupId", newPart.ItemGroup);
> record.set_field("Dimension[2]", newPart.ItemGroup);
> record.set_field("DimGroupId", newPart.DimGroup);
> record.set_field("modelGroupId", newPart.InventModelGroup);
>
> record.set_field("itemName", newPart.Description);
> record.set_field("itemId", newPart.PartNumber);
> record.set_field("NameAlias", newPart.PartNumber);
> record.set_field("CostGroupId", newPart.CostGroup);
> record.set_field("PrimaryVendorId", newPart.Vendor);
>
> // The set_fields below are the problem, I was just guessing
> // here but this does not work.
> if( newPart.ItemType == "Item" )
> record.set_field("ItemType", "ItemType::Item");
> else
> record.set_field("ItemType", "ItemType::BOM");
>
>
> I was looking for a way to create the ItemType base enum but have not
> found a way to do it yet.
>
>
> Thanks all..
>

Marcel Veldhuijzen

12/23/2005 7:23:00 AM

0

Your have to use the EnumValue integer of the enum element. Like this:

if( newPart.ItemType == "Item" )
record.set_field("ItemType", 0);
else
record.set_field("ItemType", 1);

hghrp

12/27/2005 2:38:00 PM

0

Hi Eric,

use:
record.set_field("ItemType", ItemType::Item);
else you would send a string

Hth,
harald


"EricR" wrote:

> I'm trying to create an InventTable record and need to know how to
> reference the ItemType base enum to fill in the type field.
>
> Anyone know how to do this?
>
> The basic flow of the code is:
> string axTableName = "InventTable";
>
>
> // some prep code
>
>
> IAxaptaRecord record =
> (IAxaptaRecord)_Axapta.CreateRecord(axTableName);
>
>
> record.InitValue();
> record.set_field("ItemGroupId", newPart.ItemGroup);
> record.set_field("Dimension[2]", newPart.ItemGroup);
> record.set_field("DimGroupId", newPart.DimGroup);
> record.set_field("modelGroupId", newPart.InventModelGroup);
>
> record.set_field("itemName", newPart.Description);
> record.set_field("itemId", newPart.PartNumber);
> record.set_field("NameAlias", newPart.PartNumber);
> record.set_field("CostGroupId", newPart.CostGroup);
> record.set_field("PrimaryVendorId", newPart.Vendor);
>
> // The set_fields below are the problem, I was just guessing
> // here but this does not work.
> if( newPart.ItemType == "Item" )
> record.set_field("ItemType", "ItemType::Item");
> else
> record.set_field("ItemType", "ItemType::BOM");
>
>
> I was looking for a way to create the ItemType base enum but have not
> found a way to do it yet.
>
>
> Thanks all..
>