GX model label example
For the example described in this section, assume that the Address
entity was used to create a GX model called AddressModel in a package
called com.mycompany. Several properties are included in the model, but
only the PublicID and AddressLine1 properties have the
label myAddressLabel assigned to them.
// Create an Address GX model object
var myAddress = new Address()
myAddress.PublicID = "example1234"
myAddress.AddressLine1 = "123 Main St."
myAddress.City = "Foster City"
myAddress.Description = "City on the Bay"
myAddress.PostalCode = "94404"
var addr = addressmodel.Address.create(myAddress, {addressLabel})
// Get references to myAddressLabel and the default_label in the AddressModel GX model
var addrLabel = com.mycompany.addressmodel.Address.Label.myAddressLabel
var defLabel = com.mycompany.addressmodel.Address.Label.default_label
// Create an instance of the GX model that includes only the properties with the label myAddressLabel
var addrModelLabels = com.mycompany.addressmodel.Address.create(addr, {addrLabel})
// Create an instance of the GX model that includes all properties, regardless of labels
var addrModelAll = com.mycompany.addressmodel.Address.create(addr, {defLabel})
// Output the XML contents of each model variable
print(addrModelLabels.asUTFString())
print(addrModelAll.asUTFString())
The output of the addrModelLabels variable is shown below. The output of
the addrModelAll variable is similar, but includes all the properties
contained in the model.
<?xml version="1.0"?>
<Address xmlns="http://guidewire.com/bc/gx/com.mycompany.addressmodel">
<PublicID>example1234</PublicID>
<AddressLine1>123 Main St.</AddressLine1>
</Address>
