Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need sample code for pagination #115

Open
Tameem-Ahmad-com opened this issue Oct 14, 2021 · 1 comment
Open

Need sample code for pagination #115

Tameem-Ahmad-com opened this issue Oct 14, 2021 · 1 comment

Comments

@Tameem-Ahmad-com
Copy link

i need pagination example if you have , need to fetch 100 records per page

 $page = 1;
            $query = $this->xmlQuery();
            $fetchXML = $this->xmlQuery();
            $result = $client->RetrieveMultiple($query, false, null, 100, $page, true);
            foreach ($result->Entities as $contact) {
                $cont=Contacts::updateOrCreate(['crm_id'=>$contact->contactid],[
                    'crm_id'=>$contact->contactid,
                    'crm_contact_array'=>$contact,
                    'is_from_crm'=>1,
                    'is_posted'=>0,
                    
                ]);
        
                // dispatch(new CreateUpdateHubspotContactJob());
            }
            while ($result->MoreRecords) {
                $data = sprintf($fetchXML, htmlentities($result->PagingCookie, ENT_COMPAT | ENT_XML1), ++$page);
                $result = $client->RetrieveMultiple($data);
                foreach ($result->Entities as $contact) {
                    $cont=Contacts::updateOrCreate(['crm_id'=>$contact->contactid],[
                        'crm_id'=>$contact->contactid,
                        'crm_contact_array'=>$contact,
                        'is_from_crm'=>1,
                        'is_posted'=>0,
                        
                    ]);
            
                    // dispatch(new CreateUpdateHubspotContactJob());
                }
            }
@georged
Copy link
Contributor

georged commented Oct 15, 2021

@Tameem-Ahmad-com
you're almost there. Just increment $page while you have $result->MoreRecords. paging cookie is a performance measure, read more about it at https://docs.microsoft.com/powerapps/developer/data-platform/org-service/page-large-result-sets-with-fetchxml
HTH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants