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

Add conditional handling after queries of SF Data #439

Open
acrosman opened this issue Jul 13, 2021 · 3 comments
Open

Add conditional handling after queries of SF Data #439

acrosman opened this issue Jul 13, 2021 · 3 comments

Comments

@acrosman
Copy link

It would be helpful to be able to add data conditionally into a recipe depending on the results of the the SalesforceQuery.find_record plugin. Basically being able to add the data if the record is missing, while also being able to safely re-run a recipe against an org to expand a test data set after an initial pass.

Building off the example of the existing feature in the new docs. this would be something like:

- plugin: snowfakery.standard_plugins.Salesforce.SalesforceQuery
- object: Contact
  fields:
    FirstName: Bobby
    LastName: McFerrin
  friends:
    - object: CampaignMember
      fields:
        ContactId:
          reference: Contact
        CampaignId:
          if:
            - choice: 
                when: SalesforceQuery.find_record:
                    from: Campaign
                    where: name='Happiness Campaign'
                pick: SalesforceQuery.found_record
            - choice:
                pick: 
                - object: Campaign
                    fields:
                        name: Happiness Campaign
@MannyAdumbire
Copy link

Hey there @acrosman !
I think this feature would be extremely helpful.

Is there a current solution or workaround?

I opened another issue that maybe duplicate of this, but wasn't sure if what I found is lack of feature, or if it is an actual error.
#658

@acrosman
Copy link
Author

acrosman commented May 8, 2022

There isn't a solution within Snowfakery that I'm aware of at the moment. You could probably write a plugin that does it, but you'd likely have to re-implement much of the existing Salesforce Query plugin along the way -- which I don't recommend.

Another approach might be a CCI flow that checks for the record(s), runs a task to create as needed, and then runs the main recipe.

If you have just one or two records to check for it might make sense to just excerpt the needed records into their own recipe and add conditionally. That's essentially what we do for the NPSP Opportunity Naming setup in the sample recipe collection.

@MannyAdumbire
Copy link

@acrosman thanks for the ideas!
I'll give the the cci flow route a try.

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