SFDO-Tooling / Snowfakery

A tool for generating fake data that has relations between tables.
BSD 3-Clause "New" or "Revised" License
143 stars 32 forks source link

Issue while trying to create Person Accounts in Salesforce with snowfakery recipe and Cumulus CI #648

Open jorgesolebur opened 2 years ago

jorgesolebur commented 2 years ago

Hello

I am trying to create a simple recipe to load PersonAccounts in Salesforce:

- plugin: snowfakery.standard_plugins.Salesforce
- plugin: snowfakery.standard_plugins.Salesforce.SalesforceQuery

- object: Account
  fields:
    FirstName:
      fake: FirstName
    LastName:
      fake: LastName
    PersonMailingStreet:
      fake: StreetAddress
    PersonMailingCity:
      fake: City
    PersonContactId:
      Salesforce.SpecialObject: PersonContact

However when I run this using cumulusCI with the following command:

cci task run generate_and_load_from_yaml --org dev --bulk-mode SERIAL --generator_yaml snowflake/campaign/campaign.yaml --working_directory ./tmp/ 

I get the following error from the command:

[04/28/22 15:08:59] Field Contact.IsPersonAccount is not present or does not have the correct permissions.   

I have verified and PersonAccounts is enabled in my org, and I have tested the creation of 1 person account through UI and I can successfully create one. I am attaching the yaml file and the tmp yaml files generated. How are person accounts created? Are you first creating an account, then creating a contact for that account and updating Contact.isPesonAccount = true? I do not think that will work

Thanks in advance Archive.zip

jorgesolebur commented 2 years ago

Sharing the tracebok when enabling Debug Logs:

Traceback (most recent call last):
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/cli/cci.py", line 89, in main
    cli(args[1:], standalone_mode=False, obj=runtime)
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/cli/task.py", line 181, in run_task
    task()
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/core/tasks.py", line 160, in __call__
    self.result = self._run_task()
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/generate_and_load_data.py", line 146, in _run_task
    res = self._generate_batch(
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/generate_and_load_data.py", line 213, in _generate_batch
    return self._dataload(subtask_options)
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/generate_and_load_data.py", line 175, in _dataload
    subtask()
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/core/tasks.py", line 160, in __call__
    self.result = self._run_task()
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/load.py", line 121, in _run_task
    self._init_mapping()
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/load.py", line 511, in _init_mapping
    validate_and_inject_mapping(
  File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/mapping_parser.py", line 517, in validate_and_inject_mapping
    raise BulkDataException(
cumulusci.core.exceptions.BulkDataException: One or more schema or permissions errors blocked the operation.
If you would like to attempt the load regardless, you can specify '-o drop_missing_schema True' on the command.
prescod commented 2 years ago

I believe this is a bug but I also think you can work around it by specifying -o drop_missing_schema True. That worked for me.

On Thu, Apr 28, 2022 at 12:29 AM Jorge @.***> wrote:

Sharing the tracebok when enabling Debug Logs:

Traceback (most recent call last): File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/cli/cci.py", line 89, in main cli(args[1:], standalone_mode=False, obj=runtime) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1128, in call return self.main(args, kwargs) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/click/core.py", line 754, in invoke return __callback(args, **kwargs) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/cli/task.py", line 181, in run_task task() File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/core/tasks.py", line 160, in call self.result = self._run_task() File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/generate_and_load_data.py", line 146, in _run_task res = self._generate_batch( File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/generate_and_load_data.py", line 213, in _generate_batch return self._dataload(subtask_options) File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/generate_and_load_data.py", line 175, in _dataload subtask() File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/core/tasks.py", line 160, in call self.result = self._run_task() File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/load.py", line 121, in _run_task self._init_mapping() File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/load.py", line 511, in _init_mapping validate_and_inject_mapping( File "/Users/jsolerburguera/.local/pipx/venvs/cumulusci/lib/python3.10/site-packages/cumulusci/tasks/bulkdata/mapping_parser.py", line 517, in validate_and_inject_mapping raise BulkDataException( cumulusci.core.exceptions.BulkDataException: One or more schema or permissions errors blocked the operation. If you would like to attempt the load regardless, you can specify '-o drop_missing_schema True' on the command.

— Reply to this email directly, view it on GitHub https://github.com/SFDO-Tooling/Snowfakery/issues/648#issuecomment-1111845199, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAFMSZKGVYNVSKD5TDEOILVHI46PANCNFSM5URNQ3KA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jorgesolebur commented 2 years ago

Thanks @prescod , I will give a try. Quick question - which command should I use among the 2 below? I am confused because both of them do similar things:

cci task run snowfakery 

or

cci task run generate_and_load_from_yaml

Thanks for the advice !

prescod commented 2 years ago

Snowfakery is the more modern command and highly performant/scalable.

generate_and_load_from_yaml is simpler and slower at scale, but occasionally more reliable/understandable in weird situations for those same reasons.

This is admittedly a bit of a mess and I will endeavour to improve the reliability/understandability of the snowfakery task until the old one is never needed anymore. The old one may also be faster for small datasets.

jorgesolebur commented 2 years ago

Great, thanks for the input