How to Add a New Record to Company Parameter


Basic principle
table = api.findLookupTable("VAT")
def values = [ lookupTableId: table.id, name:"vegetables", value: 0]
api.addOrUpdate("LTV", values) // change for MLTV, MLTV2, ..., MLTV6 in case of Matrix Type with 1, 2 or 6 keys respectively
Advanced version
def getLookupTableValueTypeCode(Object table) {
  switch(table.valueType.toLowerCase()) {
    case "string" :
    case "int" :
    case "real" :
    case "date" :
        return "LTV"
    case "matrix6" :
        return "MLTV6"
    case "matrix5" :
        return "MLTV5"
    case "matrix4" :
        return "MLTV4"    
    case "matrix3" :
        return "MLTV3"
    case "matrix2" :
        return "MLTV2"
    case "matrix" :
        return "MLTV"   
    default :
        return null; // must not happen
  }
}
 
def table = api.findLookupTable("VAT")
def typeCode = getLookupTableValueTypeCode(table)
def values = [ lookupTableId: table.id, name:"alcohol", value: 130 ]
api.addOrUpdate(typeCode, values)

Found an issue in documentation? Write to us.