Skip to content
Snippets Groups Projects
Commit d153c863 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix data alias querry

parent 29a2debd
No related branches found
No related tags found
No related merge requests found
import("system.SQLTYPES");
import("system.result");
import("system.vars");
import("system.calendars");
import("system.db");
import("Sql_lib");
import("Keyword_lib");
import("KeywordRegistry_basic");
var sqlQuery, sqlHelper, queryCondition, affectedIds;
queryCondition = "";
if (vars.exists("$local.idvalue")) {
affectedIds = vars.get("$local.idvalue");
queryCondition = "where OFFERID in ('" + affectedIds.map(function (v){return db.quote(v);}).join("', '") + "')";
//TODO: refactor this for incremental indexer (injections?)
}
sqlHelper = new SqlMaskingUtils();
sqlQuery = "select SALESORDERID, "
+ sqlHelper.concat([sqlHelper.cast("SALESORDERCODE", SQLTYPES.CHAR, 10), KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.salesorderState(), "SALESORDER.STATUS")], " | ")
+ " as TITLECOLUMN, "
+ sqlHelper.concat(["ORGANISATION.NAME"], " | ")
+ " as DESCCOLUMN, SALESORDERCODE, ORGANISATION.NAME, CUSTOMERCODE "
+ " from SALESORDER "
+ " join CONTACT on SALESORDER.CONTACT_ID = CONTACTID "
+ " join ORGANISATION on ORGANISATIONID = CONTACT.ORGANISATION_ID "
+ queryCondition + " order by SALESORDERCODE ";
import("system.SQLTYPES");
import("system.result");
import("system.vars");
import("system.calendars");
import("system.db");
import("Sql_lib");
import("Keyword_lib");
import("KeywordRegistry_basic");
var sqlQuery, sqlHelper, queryCondition, affectedIds;
queryCondition = "";
if (vars.exists("$local.idvalue")) {
affectedIds = vars.get("$local.idvalue");
queryCondition = "where SALESORDERID in ('" + affectedIds.map(function (v){return db.quote(v);}).join("', '") + "')";
//TODO: refactor this for incremental indexer (injections?)
}
sqlHelper = new SqlMaskingUtils();
sqlQuery = "select SALESORDERID, "
+ sqlHelper.concat([sqlHelper.cast("SALESORDERCODE", SQLTYPES.CHAR, 10), KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.salesorderState(), "SALESORDER.STATUS")], " | ")
+ " as TITLECOLUMN, "
+ sqlHelper.concat(["ORGANISATION.NAME"], " | ")
+ " as DESCCOLUMN, SALESORDERCODE, ORGANISATION.NAME, CUSTOMERCODE "
+ " from SALESORDER "
+ " join CONTACT on SALESORDER.CONTACT_ID = CONTACTID "
+ " join ORGANISATION on ORGANISATIONID = CONTACT.ORGANISATION_ID "
+ queryCondition + " order by SALESORDERCODE ";
result.string(sqlQuery);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment