Notifications
Clear all

How do I avoid hardcoding the model and MDF field constants?

4 Posts
3 Users
0 Reactions
989 Views
0
Topic starter

Is there a better of doing the following:

shipmentLine.getMDF("OMS", "PONumber")

Hard coding the constants for the model (OMS) and field (PONumber) smells funny.

2 Answers
0
Topic starter

A better way is:

shipmentLine.getMDF(ShipmentLineMDFS.class)).getPONumber()

And similarly to set the value:

shipmentLine.getMDF(ShipmentLineMDFS.class)).setPONumber("whatever")
Swaroop Bhupathiraju 2013-11-26 15:11:00

What to do if the mdf is defined in a different module?
For example, there is an mdf called international defined on shipment header model in SCC module.
What should i do to set the mdf value from TMS module without hardcoding the module prefix like
shipment.setMDF("TMS", "International", false);

Swaroop Bhupathiraju 2013-11-26 16:11:00

// use the MDFs class from the specific module in which mdf is defined
shipment.getMDF(com.onenetwork.scc.ShipmentHeaderMDFs.class).setInternational(false);

0

If its a "*.model" you can use the the "Spy" class. Fill in your "MODEL" and "Field".

MODELSpy.FIELD