Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Getting data into dynamic content

bhargav ram
Tera Contributor

Hello All,

var gr = new GlideRecord('t_record');
gr.addQuery('sys_created_on','>=',"2024-02-01");
gr.addQuery('sys_created_on','<=',"2024-02-31");
gr.addQuery('producer.sys_name','=',"sample");
gr.query();
var c=0;
while(gr.next()){
c++;
}

In dynamic content block i have done this i need to get 621 records present but i am getting 500 only and if records less than 500 are present then i am getting exact value. If more than 500 records present it directly shows 500 only.

1 ACCEPTED SOLUTION

Martin iTSM
Tera Guru

Hey there,

what does the value of gr.getRowCount()); show after gr.query();?
Did you try to create the same filter in the condition builder in the list view of the table [t_record]?
If you get you 621 records there - copy the query and do an gr.addEncodedQuery('your_copied_query_string_here'); instead of your 3 gr.addQuery(...) lines and see if that changes anything?

If you still get max 500 records maybe there`s a limitation on those dynamic content blocks - but i didn`t find any sys_properties on a first look.

Tried with this script to query the [sys_user] table and got 624 which matches the list count - so it doesn`t look like there`s a limitation:

 

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate var="jvar_test" object="false" jelly="true">

        var count=0;

        var gr= new GlideRecord('sys_user');
        gr.query();
		count = gr.getRowCount();
		count;

</g:evaluate>
User count is: ${jvar_test}   
</j:jelly>

 


Cheers!

Martin

View solution in original post

5 REPLIES 5

Maddysunil
Kilo Sage

@bhargav ram 

Can you try below code :

 

var gr = new GlideRecord('t_record');
gr.addQuery('sys_created_on', '>=', '2024-02-01');
gr.addQuery('sys_created_on', '<=', '2024-02-29');
gr.addQuery('producer.sys_name', '=', 'sample');
gr.setLimit(1000); // Set your desired limit
gr.query();

var c = 0;
while (gr.next()) {
    c++;
    // Process your records
}

 

Kindly mark helpful/accepted if it helps you.

Thanks