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

LIMIT in SOQL #4

Closed
ajayyearup opened this issue Jan 29, 2019 · 1 comment
Closed

LIMIT in SOQL #4

ajayyearup opened this issue Jan 29, 2019 · 1 comment

Comments

@ajayyearup
Copy link

How do we LIMIT the number of records?

example:
I would like to bring only 10 Accounts with associated contacts and opportunities.

Regards,
Ajay

@codeulike
Copy link
Owner

Hi Ajay

This is a tricky one because if you are transferring related objects you need to come up with something which will work for all levels of the hierarchy.

One thing you might be able to do is add a custom field specifically for marking the 10 accounts you want to transfer to sandboxes. I.e. you create a new field called Help_Sandbox_Data_Set__c on Account and then filter Account like this:

<SbbObject ApiName="Account" Filter="Help_Sandbox_Data_Set__c = true" />

For the next level down, say Contact, you can reference the same field on the parent Account object:

<SbbObject ApiName="Contact" Filter="Account.Help_Sandbox_Data_Set__c = true" />

If you can't add a field then another way of doing this - which is a little weird - is to catch a subset of records by doing a 'like' on a numeric field. You can't use the actual salesforce 'Id' in this way but if you have some other numeric ID-style field you might be able to do:

<SbbObject ApiName="Account" Filter="Internal_Reference__c like '%38'" />

... where the 38 is a random selection of digits, but in general doing like '%38' will return roughly 1% of the records. If you chose 3 random digits like '%384' you would get 0.1% of the records, and so on.

Then at the next level down, you do it again, referencing the parent field like this:

<SbbObject ApiName="Contact" Filter="Account.Internal_Reference__c like '%38'" />

Hope that helps.

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