var debug = "found" var debugtitle = "string" let curr = dv.current(); let {tabletype, invtype, dateadded, style, stage, ccy, theme, tradingd, tradingp} = input; let page = dv.pages() .filter(p => {return !p.file.path.contains('00.') && p.DocType !== undefined && p.DocType !== null && p.DocType.contains('Investment')}) function PDataCheck(arg1, arg2) { var iarg1 = arg1 if (moment(iarg1).isValid()) {iarg1 = arg1.toString()} var iarg2 = arg2 if (moment(iarg2).isValid()) {iarg2 = arg2.toString()} if (!Array.isArray(iarg2)) { var resultdc = iarg1.contains(iarg2) } else if (!Array.isArray(iarg1)) { var resultdc = iarg2.contains(iarg1) } else { let count = iarg2.length let tempresult = false for (let i = 0; i < count; i++) { tempresult = tempresult || iarg1.contains(iarg2[i]) } var resultdc = tempresult } return resultdc } function IsInPSearch(argobj) { if (Boolean(invtype)) { var result_itype = PDataCheck(argobj.Investment.Type, invtype) } else {var result_itype = true} if (Boolean(theme)) { var result_tag = PDataCheck(argobj.Tag, theme) } else {var result_tag = true} if (Boolean(dateadded)) { var result_date = PDataCheck(argobj.Date, dateadded) } else {var result_date = true} if (Boolean(style)) { var result_style = PDataCheck(argobj.Investment.Style, style) } else {var result_style = true} if (Boolean(stage)) { if (argobj.Investment.Stage == undefined) {var result_stage = false} else { var result_stage = PDataCheck(argobj.Investment.Stage, stage) } } else {var result_stage = true} if (Boolean(ccy)) { var result_ccy = PDataCheck(argobj.Investment.Ccy, ccy) } else {var result_ccy = true} if (Boolean(tradingd)) { var result_tradd = PDataCheck(argobj.Trading.PDate, tradingd) } else {var result_tradd = true} if (Boolean(tradingp)) { var result_tradp = PDataCheck(argobj.Trading.PPrice, tradingp) } else {var result_tradp = true} var resultiid = result_itype && result_tag && result_date && result_stage && result_style && result_ccy && result_tradp && result_tradd return resultiid } if (page.length > 0 && (tabletype == 'overview')) { dv.table(["Name", "Currency", "Style", "Stage", "Themes"], page .where(p => p && IsInPSearch(p)) .sort(p => p.file.name, `asc`) .map(p => [p.file.link, p.Investment.Ccy, p.Investment.Style, p.Investment.Stage, p.Tag])); } else if (page.length > 0 && (tabletype == 'trading')) { dv.table(["Name", "Currency", "Trading date", "Trading price"], page .where(p => p && IsInPSearch(p)) .sort(p => p.file.name, `asc`) .map(p => [p.file.link, p.Investment.Ccy, p.Trading.PDate, p.Trading.PPrice])); } else { return '"No result matching your query"'}