a!localVariables( local!icons: rule!EUR_IconList(), reject( fn!isnull, a!forEach( items: ri!documents, expression: a!localVariables( local!document: fv!item, local!isRecord: not(rule!EUR_isEmpty(xpathdocument( fv!item, "//recordType/@name" ))), local!isCdt: not(rule!EUR_isEmpty(xpathdocument( fv!item, "//*[local-name()='complexType']/@name" ))), local!isExpressionBacked: if( local!isRecord, tostring(xpathdocument( fv!item, "//recordType/*[local-name()='source']/@*[local-name()='type']" )) = "a:Datatype", false ), if( or( and( local!isRecord, not(local!isExpressionBacked) ), local!isCdt ), a!localVariables( local!name: tostring(xpathdocument( docId: fv!item, expression: if( local!isRecord, "//recordType/@name", "//*[local-name()='complexType']/@name" ) )), local!pluralName: if( local!isRecord, tostring(xpathdocument( docId: fv!item, expression: "//*[local-name()='pluralName']/text()" )), local!name ), local!uuid: if( local!isRecord, tostring(xpathdocument( docId: fv!item, expression: "//recordType/@*[local-name()='uuid']" )), "{" & tostring(xpathdocument( docId: fv!item, expression: "//*[local-name()='schema']/@targetNamespace" )) & "}" & tostring(xpathdocument( docId: fv!item, expression: "//*[local-name()='complexType']/@name" )) ), local!fieldsXml: xpathdocument( docId: fv!item, expression: if( local!isRecord, "//*[local-name()='sourceConfiguration']//field", "//*[local-name()='element']" ) ), local!dataStoreEntityUuidResult: if( local!isRecord, tostring(xpathdocument( docId: fv!item, expression: "//*[local-name()='source']/@*[local-name()='uuid']" )), null ), local!dataStoreEntityUuid: if( rule!EUR_isBlank(local!dataStoreEntityUuidResult), null, index(split(local!dataStoreEntityUuidResult, "@"), 1, null) ), local!dataType: if( rule!EUR_isBlank(local!dataStoreEntityUuidResult), null, reject( fn!isnull, a!flatten(a!forEach( items: ri!documents, expression: xpathdocument( docId: fv!item, expression: "//entity[uuid = '" & local!dataStoreEntityUuid & "']/type/text()" ) )) ) ), local!fields: reject( fn!isnull, a!forEach( local!fieldsXml, if( local!isRecord, 'type!{urn:com:appian:types:EUR}EUR_RecordTypeField'( uuid: tostring(xpathsnippet(fv!item, "//uuid/text()")), type: tostring(xpathsnippet(fv!item, "//type/text()")), sourceFieldName: tostring( xpathsnippet(fv!item, "//sourceFieldName/text()") ), sourceFieldType: tostring( xpathsnippet(fv!item, "//sourceFieldType/text()") ), fieldName: tostring( xpathsnippet(fv!item, "//fieldName/text()") ), isRecordId: toboolean( tostring( xpathsnippet(fv!item, "//isRecordId/text()") ) ), isUnique: toboolean( tostring( xpathsnippet(fv!item, "//isUnique/text()") ) ), isCustomField: toboolean( tostring( xpathsnippet(fv!item, "//isCustomField/text()") ) ), fieldCalculationType: tostring( xpathsnippet(fv!item, "//fieldCalculationType/text()") ) ), if( rule!EUR_MapXsdToAppianTypes(xsdType: xpathsnippet(fv!item, "//@type")) <> cons!EUR_APPIAN_TYPES[8], 'type!{urn:com:appian:types:EUR}EUR_RecordTypeField'( uuid: tostring(xpathsnippet(fv!item, "//@name")), type: tostring(rule!EUR_MapXsdToAppianTypes(xsdType: xpathsnippet(fv!item, "//@type"))), fieldName: tostring(xpathsnippet(fv!item, "//@name")), isRecordId: rule!EUR_ExtractIsRecordId( appinfo: tostring(xpathsnippet(fv!item, "//*[local-name()='appinfo']/text()")) ), isUnique: rule!EUR_ExtractIsUnique( appinfo: tostring(xpathsnippet(fv!item, "//*[local-name()='appinfo']/text()")) ), isCustomField: false, fieldCalculationType: "NA" ), null ) ) ) ), local!relationships: if( local!isRecord, if( rule!EUR_isBlank(local!dataStoreEntityUuidResult), a!forEach( xpathdocument( docId: fv!item, expression: "//*[local-name()='recordRelationshipCfg']" ), 'type!{urn:com:appian:types:EUR}EUR_RecordTypeRelationship'( uuid: tostring(xpathsnippet(fv!item, "//uuid/text()")), targetRecordTypeUuid: tostring(xpathsnippet(fv!item, "//targetRecordTypeUuid/text()")), relationshipName: tostring(xpathsnippet(fv!item, "//relationshipName/text()")), relationshipType: tostring(xpathsnippet(fv!item, "//relationshipType/text()")), isCdt: false ) ), 'type!{urn:com:appian:types:EUR}EUR_RecordTypeRelationship'( targetRecordTypeUuid: local!dataType, relationshipName: local!name, relationshipType: cons!EUR_RELATIONSHIP_TYPES[1], isCdt: true ) ), reject( fn!isnull, a!forEach( local!fieldsXml, if( rule!EUR_MapXsdToAppianTypes(xsdType: xpathsnippet(fv!item, "//@type")) = cons!EUR_APPIAN_TYPES[8], 'type!{urn:com:appian:types:EUR}EUR_RecordTypeRelationship'( targetRecordTypeUuid: rule!EUR_ExtractUuid( document: local!document, type: tostring(xpathsnippet(fv!item, "//@type")) ), relationshipName: tostring(xpathsnippet(fv!item, "//@name")), relationshipType: rule!EUR_ExtractRelationshipType( appinfo: tostring(xpathsnippet(fv!item, "//*[local-name()='appinfo']/text()")) ), cascadeType: rule!EUR_ExtractCascadeType( appinfo: tostring(xpathsnippet(fv!item, "//*[local-name()='appinfo']/text()")) ), isCdt: true ), null ) ) ) ), local!filtersXml: xpathdocument( docId: fv!item, expression: "//*[local-name()='fieldCfg']" ), local!filters: if( local!isRecord, a!forEach( items: local!filtersXml, expression: 'type!{urn:com:appian:types:EUR}EUR_RecordTypeFilter'( uuid: tostring(xpathsnippet(fv!item, "//@*[local-name()='uuid']")), name: tostring(xpathsnippet(fv!item, "//@name")), ) ), null ), local!relatedActionsXml: xpathdocument( docId: fv!item, expression: "//recordType/*[local-name()='relatedActionCfg']" ), local!relatedActions: if( local!isRecord, a!forEach( items: local!relatedActionsXml, expression: 'type!{urn:com:appian:types:EUR}EUR_RecordTypeAction'( uuid: tostring(index(xpathsnippet(fv!item, "//@*[local-name()='uuid']"), 1, null)), name: tostring(xpathsnippet(fv!item, "//*[local-name()='staticTitleString']/text()")), icon: displayvalue( tostring(xpathsnippet(fv!item, "//*[local-name()='iconId']/text()")), local!icons.id, local!icons.friendlyName, null ), isRelated: true ) ), null ), local!listActionsXml: xpathdocument( docId: fv!item, expression: "//recordType/*[local-name()='recordListActionCfg']" ), local!listActions: if( local!isRecord, a!forEach( items: local!listActionsXml, expression: 'type!{urn:com:appian:types:EUR}EUR_RecordTypeAction'( uuid: tostring(index(xpathsnippet(fv!item, "//@*[local-name()='uuid']"), 1, null)), name: tostring(xpathsnippet(fv!item, "//*[local-name()='staticTitle']/text()")), nameExpr: tostring(xpathsnippet(fv!item, "//*[local-name()='titleExpr']/text()")), icon: displayvalue( tostring(xpathsnippet(fv!item, "//*[local-name()='iconId']/text()")), local!icons.id, local!icons.friendlyName, null ), isRelated: false ) ), null ), local!actions: a!flatten({ local!relatedActions, local!listActions }), 'type!{urn:com:appian:types:EUR}EUR_RecordType'( name: local!name, pluralName: local!pluralName, uuid: local!uuid, fields: local!fields, relationships: local!relationships, dataStoreEntityUuid: local!dataStoreEntityUuid, filters: local!filters, actions: local!actions, isCdt: local!isCdt ) ), null ) ) ) ) )