Writing a Groovy Script

The following is a code example for a Resource Generator which generates a file containing only resource objects.

setCurrentObjectName(context, "Resource");
def fieldNameCount = getFieldNameCount(context);
if (fieldNameCount > 0) {

def fieldNameIndex = 0;
while (fieldNameIndex < fieldNameCount) {
def fieldName = getFieldNameByIndex(context, fieldNameIndex);
writeCell(context, fieldName);
fieldNameIndex = fieldNameIndex + 1;
}
newline(context);
def objectCount = getObjectCount(context);
def objectIndex = 0;
while (objectIndex < objectCount) {
setCurrentObject(context, objectIndex);

fieldNameIndex = 0;
while (fieldNameIndex < fieldNameCount) {
def fieldName = getFieldNameByIndex(context, fieldNameIndex);
def value = getFieldValue(context, fieldName);
writeCell(context, value);
fieldNameIndex = fieldNameIndex +1;
}
newline(context);
objectIndex = objectIndex + 1;
}
}



Legal Notices | Your Privacy Rights
Copyright © 2018 2022

Last Published Monday, January 31, 2022