Combination of OData filter functions (replace inside startswith)
Hi,
we've to a column with chapter numbers. This column is formated as s string and is designt to extend the numbers with leading spaces, so each chapter / subchapter is 4 chars log.
e.g.: " 3. 2. 1."
if i want to filter by chapter and "startswith", the user has to insert the spaces in the csl as well....
OData offers a function "replace". So i thought i can use something like:
startswith(replace(Chapter,' ',''),'" + encodeURIComponent(term) + "')
but this only results in an error.
How can i filter and ignore whitespaces?
we've to a column with chapter numbers. This column is formated as s string and is designt to extend the numbers with leading spaces, so each chapter / subchapter is 4 chars log.
e.g.: " 3. 2. 1."
if i want to filter by chapter and "startswith", the user has to insert the spaces in the csl as well....
OData offers a function "replace". So i thought i can use something like:
startswith(replace(Chapter,' ',''),'" + encodeURIComponent(term) + "')
but this only results in an error.
How can i filter and ignore whitespaces?
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Ragesoft,
This might be doable, but will require you to have at least one Or filter operation, so you'll need to check multiple conditions. You'll also need to use JavaScript to dynamically add spaces to the correct places in the string, then encode it. This is no easy task, but might be possible.
What you might do here is launch a Workflow or Flow which will remove spaces from the column, and re-save value to a new column in the same list. Then filter by the current column OR by the newly created one. This should be the simplest solution possible.
This might be doable, but will require you to have at least one Or filter operation, so you'll need to check multiple conditions. You'll also need to use JavaScript to dynamically add spaces to the correct places in the string, then encode it. This is no easy task, but might be possible.
What you might do here is launch a Workflow or Flow which will remove spaces from the column, and re-save value to a new column in the same list. Then filter by the current column OR by the newly created one. This should be the simplest solution possible.
Cheers
I've solved the problem for now by just adding leading whitespaces
And in the filter i have two times "startswith" and "OR" not best, but working solution....
Code: Select all
var termSplit = term.split(".");
$.each(termSplit,function(index, value){
if(value){
var a = (value.length<4?5-value.length:0);
termSplit[index] = new Array(a).join(' ') + value;
}
});
var termSpaced = termSplit.join(".");
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear ragesoft,
Actually really glad to hear that you've found a solution. Great work!
Actually really glad to hear that you've found a solution. Great work!
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests