Sometimes all you know about a data entity record is its unique key string. This can be from a reference to a  parent record, passed as miscellaneous input to a BOS method, or in MVC applications it can be passed through a url query parameter or post body.

The unique key string is a concatenation of the entity's [AB_Key] properties. To access those individual properties, use the am_ParseUniqueKeyIntoProperties() method:

var customerPartEntity = new OECustomerPartEntity { ap_UniqueKey = InputArgs.ap_MiscellaneousInput };
customerPartEntity.am_ParseUniqueKeyIntoProperties();
ode.CUSTOMERPARTNUMBER = customerPartEntity.PartNumber;

In this example the key was passed in ap_MiscellaneousInput. It could have originally come from either the ap_UniqueKey or the ap_CompactUniqueKey property on the entity. A new entity is created an ap_UniqueKey is set to the key string, and then am_ParseUniqueKeyIntoProperties() is called. This will set all of the [AB_Key] properties, which can then be accessed individually.

To get other fields, the entity can be used as input to either am_Fetch or am_Select once its [AB_Key] fields are set. Though, in this case the call to am_ParseUniqueKeyIntoProperies() isn't necessary if am_Fetch() is used, because am_Fetch() will call it automatically.