Writing EDFs

You can add EDFs to views, actions, action screens and interfaces using the EPT editor. (EDFs aren't available in MPTs or SPTs.) If you have added an EDF in an action screen or view, the field should be available on the UI just like any other field. You will be able to provide a value for it to be saved into the database.

To programmatically write an EDF on a model, use the following syntax:

Book book = new Book();
//set Natural Keys
book.setTitle("Bookstore Tutorial");
//set EDFs
//set string or string enumeration field
book.setAttribute("EPT.BookstoreEPT.TestString", "SampleValue");
//set number field
book.setAttribute("EPT.BookstoreEPT.TestInteger", 10);
book.setAttribute("EPT.BookstoreEPT.TestDouble", 10.2);
//set duration field
DurationValue durationValue = new DurationValue();
durationValue.setValue("P1DT1H1M");
book.setAttribute("EPT.BookstoreEPT.TestDuration", durationValue);
//set model link field
ModelLinkAttributeValue modelLink = new ModelLinkAttributeValue();
model.setAttribute("EPT.BookstoreEPT.TestModelLink", modelLink);
//set all the model link NK components using the set method on ModelLinkAttributeValue
modelLink.set("EPT.BookstoreEPT.TestModelLinkName", "SampleEnterprise");
//set Address field
Address address = Services.get(AddressService.class).createAddress(CountryCodes.US);
address.set(AddressComponentType.STREET_1, testCaseName);
address.set(AddressComponentType.CITY, testCaseName);
address.set(AddressComponentType.STATE, "TX");
model.setAttribute("EPT.BookstoreEPT.TestAddress", address);
//set composite field
//for composite field, you will need to set all the components seperately
model.setAttribute("EPT.BookstoreEPT.TestCompositeAmount", 100.00);
model.setAttribute("EPT.BookstoreEPT.TestCompositeCurrency", CurrencyCode.USD.getValue());
// write model to database using ModelDataService

You should use an Enterprise level user who has access to the EPT to write the EDFs. If you use ValueChainAdmin or any other enterprise-level user who doesn't have access to the EPT, the platform will raise an error if EDFs are set.

Also, if your model has any unrecognized EDF then the platform will raise an error.

If you want to nullify the value of an attribute in the database, you should use set it to the corresponding com.onenetwork.platform.data.model.NullConstants value, just as you would for a regular model field.