0 votes

Hi all,

With ConsultDetail I get the Documents of an Opportunity, but I want to filter this dataset on quotes : a quote have a REFERENCE that start by 'D'.

The EDN say that TDataSet.Filter is "The text of the current SQL filter for the dataset." so I try to filter my dataset with REFERENCE LIKE 'D%' but Efficy throw me this error :

ID: WKFL-2142
Message: Error while executing Script "OppoConvertToProj" at line 52 char 13.
Message: "L'URI à décoder contient un caractère incorrect"

After some tests I know that the error is thorwn by the % . I tried to fix it in the "CleanFilter" (replace % by %) but I have the same error.

Is it possible to filter a dataset with a like ?

Here is my filter (first recordCount is correct, the second is empty)

// copy links to quote ==> CUSTOM : Create new Document (ORDER)
var OppoDocuDS = Database.ConsultDetail(QueryHandle, OppoContext, OppoKey, ntDocu, true, true, 0);
Logger.Write('OppoDocuDS.recordCount1='+OppoDocuDS.recordCount);
Logger.Write('OppoDocuDS.IsEmpty1='+OppoDocuDS.IsEmpty);

// filter dataset on quote
var Filter = "REFERENCE LIKE 'D%'";
var CleanFilter = decodeURIComponent(Filter).replace(/=/gi, "=").replace(/</gi, "<").replace(/>/gi, ">").replace(/&#37;/gi, "%")
OppoDocuDS.Filtered = false
if (CleanFilter != "") {
    OppoDocuDS.Filter = CleanFilter
    OppoDocuDS.FilterOptions = 1
    OppoDocuDS.Filtered = true
}

Logger.Write('OppoDocuDS.recordCount2='+OppoDocuDS.recordCount);
Logger.Write('OppoDocuDS.IsEmpty2='+OppoDocuDS.IsEmpty);
asked in WorkFlow / Serverscript by (245 points)
edited by

1 Answer

0 votes

Hello.

An example can be found in standard Efficy. The filter requires indeed some cleanup.

efficy\serverscripts\PublImportFrom.js (line 112, Efficy 11.1)

var CleanFilter = decodeURIComponent(Filter).replace(/&#61;/gi, "=").replace(/&amp;#61;/gi, "=").replace(/&amp;lt;/gi, "<").replace(/&amp;gt;/gi, ">")
answered by (6.8k points)
Hi,

I know that, in the code I use it, but I don't know how to "cleanup" the %.
I tried with his HTML_ENTITIES but I have the same error
https://www.freeformatter.com/html-entities.html

I tried with
var CleanFilter = decodeURIComponent(Filter).replace(/=/gi, "=").replace(/</gi, "<").replace(/>/gi, ">").replace(/&#37;/gi, "%")
1,167 questions
1,425 answers
1,717 comments
325 users