DOES NOT START WITH filter

Anish Reghu
Kilo Sage
Kilo Sage

Dear all,

This was asked 5 years ago, unanswered. Asking it again to a much wider audience now, hopefully.

Can someone suggest that script include for DOES NOT START WITH and how to call that from a advanced filter? Please don't refer me to threads, even the thread marked as RESOLVED does not have the solution in it. Any help is appreciated.

I know one solution is to create a advanced filter and calling a script include. But I would need the solution instead of the approach.

Any answers?

 

Regards,

Anish

1 ACCEPTED SOLUTION

Filip Vojt__ek
Mega Guru

Hi Anish,

 

it's a while ago, but maybe someone will find this answer helpfull.

 

The solution from my point of view is to use SQL 'LIKE' operator which work even though it's not documented for GlideRecord:

gr.addQuery('name', 'NOT LIKE', 'StartString%');

 

Pls mark as helpful if solution works.

View solution in original post

19 REPLIES 19

DirkRedeker
Mega Sage

Hi

Can give an example of what you are looking for?

Do you want to have a Script Include with a function to check if a string "DOES NOT START WITH" a certain string?

Or are you planning to create some dynamic Filter Script, that you can use inside of Condition Builders?

Just let me know,please

BR

Dirk

I would prefer to have it in the condition builder. If that's possible, it's a good one to meet my requirement.

Brad Bowman
Kilo Patron
Kilo Patron

I'm assuming a lot of details about your requirement here, so let me know if your specifics aren't in line.  For this example I have a reference variable on a catalog item.  The variable is referencing the core_company table in my OOTB Orlando PDI.  This is what it looks like with no reference qualifier.

find_real_file.png

Now I have added an Advanced Reference qualifier

javascript:new Companies().getFilteredCOs();

I'll skip to the end and show the results first when I return records that do not start with 'ACME'.

find_real_file.png

 

To accomplish this, create a Script Include with the same name and function referenced in the qualifier.  Make sure the Client callable box is checked.  Here is the script I used for this simple example.  You could also pass in the 'does not start with' text string from another field/variable as a function parameter.

var Companies = Class.create();
Companies.prototype = {
initialize: function() {
 },
 
 getFilteredCOs:function(){
  var colist = [];
  var dnswText = 'ACME';
  var gr = new GlideRecord('core_company');
  gr.query();
  while(gr.next()){
   if(gr.name.indexOf(dnswText) == -1 || gr.name.indexOf(dnswText) != 0){ //string not found or not at beginning of Name field
   colist.push(gr.sys_id.toString());        
   }
  }
  return 'sys_idIN' + colist.join(',');
},
type: 'Companies'
};

 

 

 

Hey Brad,

I must thank you for the detailed explanation first.

Is it possible that I can dynamically enter values and get results as we do with "STARTS WITH", because if I have to change the keyword, I would have to modify the script here.

 

Thanks again,

Anish