Post

2 followers Follow
0
Avatar

Problem using Paging to perform sequential requests.

Hello,

 

I'm working with API 2.0, with CZQL queries.

I'm using the following CZQL request:

SELECT @Container, @Member
FROM GroupMembershipLink
WHERE @Container IN(
SELECT @Name
FROM UserGroup
WHERE @Name IN ('MyGroup')
) AND @Member IN (
SELECT @Name");
FROM User");
WHERE @State IN ('Active')
)
LIMIT 10

 

My code is:

 StringBuilder CZQLStrbuild = new StringBuilder();
CZQLStrbuild.AppendLine("SELECT @Container, @Member"); // Field Names are API Field Names
CZQLStrbuild.AppendLine("FROM GroupMembershipLink");
CZQLStrbuild.AppendLine("WHERE @Container IN(");
CZQLStrbuild.AppendLine(" SELECT @Name");
CZQLStrbuild.AppendLine(" FROM UserGroup");
CZQLStrbuild.AppendLine(" WHERE @Name IN ('" + iGroupName + "')");
if (iActiveUsersOnly)
{
CZQLStrbuild.AppendLine(") AND @Member IN (");
CZQLStrbuild.AppendLine(" SELECT @Name");
CZQLStrbuild.AppendLine(" FROM User");
CZQLStrbuild.AppendLine(" WHERE @State IN ('Active')");
}
CZQLStrbuild.AppendLine(")");
CZQLStrbuild.AppendLine("LIMIT " + RecordCountOnRequest);

CZQLQuery MembersQuery = new CZQLQuery();

MembersQuery.Text = CZQLStrbuild.ToString();
QueryResult result = null;

BaseMessage[] messages = new BaseMessage[] { MembersQuery };
result = (QueryResult)_clarizenClient.Execute(messages)[0];

MembersQuery.Paging = result.Paging;
messages = new BaseMessage[] { MembersQuery };
result = (QueryResult)_clarizenClient.Execute(messages)[0];

// result.Paging.Offset is 10, but I expected it to be 20.

Could anyone help me solving this problem?

Thanks in advance,

Armand BOLMONT Answered

Please sign in to leave a comment.

2 comments

1
Avatar

Hi Armand,

Please use either Paging object or the query text to specify the offset and limit.
If you specify LIMIT (and/or OFFSET) in the query text the Paging object is ignored. 

To fix the issue you should either:

  • Specify the OFFSET in the query text in addition to LIMIT (meaning you need to update the query text each page) 
  • Specify offset and limit in the message's Paging object only (remove LIMIT from the query text and initialize a Paging object for the first call as well).

Hope this helps,

Ophir

Ophir Kenig 1 vote
Comment actions Permalink