Example of Custom Method for Custom Attributes
To create a custom attribute, you must create a custom method that the attribute calls. Here is an example of how you could use eScript to write a custom method named GetValuesCustomAttribute to be used by a custom attribute.
function GetValuesCustomAttribute(inputs, outputs)
{
try{
// All the field values would be in the format Object.Field.Field Name. All the
// values would be passed to custom attributes.
// Avoid Using transaction Id and querying transaction BC, as in simulation
// mode the attributes passed in transaction are passed to simulation. Always use
// the values from the Transaction.Field.Field Name.
var strOrgAirPort = inputs.GetProperty ("Transaction.Field.Origination Airport");
var strDestAirPort = inputs.GetProperty ("Transaction.Field.Destination Airport");
var customCoeff = inputs.GetProperty ("Transaction.Field.Custom Coeff Factor");
var points = 0;
if(strOrgAirPort == "SFO" &&strDestAirPort ="BOS")
points = 200 * customCoeff;
outputs.SetProperty("Field Value",points);
}
catch(e)
{
TheApplication().RaiseErrorText(e.toString());
}
finally
{
}
}