EditorScripts Class
void template_method_ALfindRecId(Editor editor) { xppSource xppSource = new xppSource(); Dialog dialog = new Dialog("@ALA314"); DialogField dlgTableName = dialog.addField(typeid(Tablename)); Source template; ; if (dialog.run()) { template = xppSource.AL_findMethod(dlgTableName.value(), extendedTypeStr(RecId), extendedTypeStr(RecId)); editor.insertLines(template); } } void template_method_ALfind(Editor editor) { xppSource xppSource = new xppSource(); Dialog dialog = new Dialog("@ALA313"); DialogField dlgTableName = dialog.addField(typeid(Tablename)); DialogField dlgFieldName = dialog.addField(typeid(ExtendedDataTypeName)); Source template; ; if (dialog.run()) { template = xppSource.AL_findMethod(dlgTableName.value(),dlgFieldName.value()); editor.insertLines(template); } } void template_method_ALexist(Editor editor) { xppSource xppSource = new xppSource(); Dialog dialog = new Dialog("@ALA312"); DialogField dlgTableName = dialog.addField(typeid(Tablename)); DialogField dlgFieldName = dialog.addField(typeid(ExtendedDataTypeName)); Source template; ; if (dialog.run()) { template = xppSource.AL_existMethod(dlgTableName.value(),dlgFieldName.value()); editor.insertLines(template); } } XppSource class Source AL_existMethod( Tablename tableName, Fieldname fieldname ) { str selectStatement; ; tableName = strLRTrim(tableName); fieldname = strLRTrim(fieldname); tableName = strupr(substr(tableName,1,1))+substr(tableName,2,strlen(tableName)); fieldname = strlwr(substr(fieldname,1,1))+substr(fieldname,2,strlen(fieldname)); source += strfmt('public boolean exist(%1 _%1)', fieldname); source += '\n'; this.beginBlock(); source += this.indent(); source += ';'; source += '\n'; source += '\n'; source += this.indent(); source += strfmt('return _%2 && (select RecId from %1\n' + ' where %1.%2 == _%2\n' + ' ).RecId != 0;', tableName, fieldname); source += '\n'; this.endBlock(); return source; } Source AL_findMethod( Tablename tableName, Fieldname fieldname = "", str methodName = "" ) { str selectStatement; ; tableName = strLRTrim(tableName); fieldname = strLRTrim(fieldname); tableName = strupr(substr(tableName,1,1))+substr(tableName,2,strlen(tableName)); fieldname = strlwr(substr(fieldname,1,1))+substr(fieldname,2,strlen(fieldname)); source += strfmt('public %1 find%3(%2 _%2, boolean update = false)', tableName, fieldname, methodName); source += '\n'; this.beginBlock(); source += this.indent(); source += strfmt('%1 _%1;', tableName); source += '\n'; source += this.indent(); source += ';'; source += '\n'; source += '\n'; source += this.indent(); source += strfmt('_%1.selectForUpdate(update);', tableName); source += '\n'; source += '\n'; source += this.indent(); selectStatement = strfmt("select firstonly _%1\n" + // " index hint ItemIdx" + " where _%1.%2 == _%2;", tableName, fieldname); this.if(strfmt('_%1', fieldname), selectStatement); source += '\n'; source += this.indent(); source += strfmt('return _%1;', tableName); source += '\n'; this.endBlock(); return source; } --- In development-axapta@yahoogroups.com, "Leberbauer, Herbert - News" <n.herbert.leberba...@...> wrote: > > > Hi! > > Has anyone developed any Editor-Scripts for generating the Find() and > Exist()-Method for a Maintable? > > best regards > Herbert >