Hey folks, been deep in a Salesforce CPQ implementation and we hit the classic problem: our pricing rules are getting too complex for simple formulas. We have tiered discounts, competitor-based overrides, and promotional bundles that change monthly. Building and maintaining this in Clickable Rules was becoming a full-time job.
So I experimented with ChatGPT (GPT-4) to see if it could generate the logic skeletons for us. The idea was to describe the business rule in plain English and have it output the structured logic, which we'd then adapt for our system.
Here's a quick example of what I fed it and what I got back:
**My Prompt:**
"Generate a pseudo-code rule for a CRM dynamic price. If the customer is in the 'Enterprise' tier AND the opportunity amount is over $50,000, apply a 15% discount. However, if a competitor named 'CloudRival' is identified, apply an additional 5% discount (stacking) but never exceed a total discount of 25% from the base price."
**ChatGPT's Output (cleaned up):**
```javascript
// Pseudo-code for Dynamic Pricing Rule
if (account.tier == "Enterprise") {
baseDiscount = 0;
if (opportunity.amount > 50000) {
baseDiscount = 0.15;
}
if (competitor.name == "CloudRival") {
additionalDiscount = 0.05;
totalDiscount = baseDiscount + additionalDiscount;
if (totalDiscount > 0.25) {
totalDiscount = 0.25;
}
} else {
totalDiscount = baseDiscount;
}
finalPrice = basePrice * (1 - totalDiscount);
}
```
This was surprisingly solid as a starting point. I could quickly map this to Salesforce CPQ's formula syntax or even Apex triggers for more complex scenarios. It saved a ton of time on logic mapping.
However, I hit some clear pitfalls:
* The code is generic and never plug-and-play. You **must** understand your CRM's object model and formula syntax.
* It can hallucinate field names or operators that don't exist in your specific system.
* For extremely complex rules with 10+ conditions, it sometimes loses track of nested logic.
My current workflow is: ChatGPT for the initial logic block > adapt to Salesforce syntax > test in a sandbox. It's cut our rule development time by about half.
Has anyone else tried something similar? I'm curious if you've used it for generating actual Apex classes for pricing or perhaps for building Zapier tasks that feed pricing data into a CRM from an external source.
hth