Filter conditions in script

swethaa
Kilo Contributor

Hi All,

can anyone guide me how to write filter conditions for this " records created today and records created by sujith" in script?

Thanks,

sujitha

1 ACCEPTED SOLUTION

Raju Koyagura
Tera Guru

Here is the filter and make sure change the user id according to the sys_user table. 

Once you are done with below filters copy the query from filter list and add to the script

gr. addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^sys_created_by=javascript: gs.getUserName()')

 

Note: It always gives only the records created today and created by the user name we provide.

find_real_file.png

If you are looking for the created by user dynamic based on the logged in user use below filter conditions (javascript: gs.getUserName())

find_real_file.png

View solution in original post

4 REPLIES 4

Raju Koyagura
Tera Guru

Here is the filter and make sure change the user id according to the sys_user table. 

Once you are done with below filters copy the query from filter list and add to the script

gr. addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^sys_created_by=javascript: gs.getUserName()')

 

Note: It always gives only the records created today and created by the user name we provide.

find_real_file.png

If you are looking for the created by user dynamic based on the logged in user use below filter conditions (javascript: gs.getUserName())

find_real_file.png

Nikhil Dixit
Giga Expert

Hi Sujith,

You can user 'addEncodedQuery()' into your script as mention below.

var gr = new GlideRecord("tableName");

gr.addEncodedQuery(sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^sys_created_bySTARTSWITHSujith);

gr.query();

Please mark answer correct and helpful if it served your purpose.

 

Warm Regards

Nikhil Dixit

www.DxSherpa.com |

Bhagya Lakshmi
Mega Guru

Hi,

You can write like this

gr.addEncodedQuery('sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^sys_created_by=sujith');

Not applicable

Hi Sujitha,

Glide your table (eg - Incident)

var gr = new GlideRecord("incident");

gr.addEncodedQuery("sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()^sys_created_by=sujith");

gr.query();

while(gr.next())

{

//do something

}

 

Thankyou