Skip to main content

Hi everyone! Long time, no see... I hope you're all doing well. :) 

I just got back into Snowfakery after a long hiatus and wanted to check if a certain fictitious scenario was possible. 

Let's say I have an object called SalesforceRoles__c which has a bunch of different fields relating to different Salesforce roles (let's say Solution Architect, Technical Architect, Business Analyst, and Developer). I have all sorts of formulas and random_choice elements set up to randomize these fields/choices dynamically and Snowfakery is generating these perfectly. I then want to create between 1-4 friend records based on which types of fields were filled in on the SalesforceRoles__c record. So, if the Business Analyst fields were filled in, I want to create a friend record of type SalesforceRoleInterest__c with Business Analyst-specific fields filled in. If the Solution Architect info was filled in, I want to create another friend record where the Solution Architect-specific fields are filled in, etc. So, each time the recipe runs for that SalesforceRoles__c object, it can generate 1-4 friend records.

I've tried using macros for each combination of fields and then trying various types of "if" criteria to include different macros or the whole friend -> object -> macro with fields combination if certain fields are set to true on the first object.

I was hoping I could do something like this. Or maybe there's some special Python I can include?:

- friends

if ${{SFRole.BusinessAnalyst__c == 'true'}}

- object: SalesforceRoleInterest__c

fields:

# fields for BA filled in

if ${{SFRole.SolutionArchitect__ == 'true'}}

- object: SalesforceRoleInterest__c

fields:

# fields for Solution Architect filled in

Fuller Example:

- object: SalesforceRoles__c

nickname: SFRole

fields:

BusinessAnalyst__c:

random_choice:

True

False

BusinessAnalystInterests__c:

if:

- choice:

when: ${{BusinessAnalyst__c=='True'}}

pick:

${{fake.CatchPhrase}}

SolutionArchitect__c:

random_choice:

True

False

SolutionArchitectInterests__c:

if:

- choice:

when: ${{SolutionArchitect__c=='True'}}

pick:

${{fake.CatchPhrase}}

friends:

- object: SalesforceRoleInterest__c

fields:

# fields for BA filled in

- object: SalesforceRoleInterest__c

fields:

# fields for Solution Architect filled in

0/9000