- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Saturday
Hello fellow community members,
I've noticed a recurring question in the community: "How can we create multiple instances of a Requested Item, each with different variable values, all within a single request?" Think of it like a shopping cart experienceβyou add multiple items, then check out once.
Today, I'm sharing a powerful solution to achieve exactly that.
The Problem Statement
A user needs to submit multiple, distinct issues. Each submission has an Action, an Issue Type, and a unique Issue ID. The system should then generate a separate Requested Item (RITM) for each submission.
- If a user submits multiple issues with the same Action and Issue Type, the system should create multiple RITMs for the same catalog item, but each RITM should contain the different Issue ID.
- All these RITMs must be consolidated under a single Request (REQ) for easy tracking.
Why the OOB Approach Falls Short
At first glance, an Order Guide seems like a good fit. It can certainly trigger different catalog items based on user input. However, its main limitation is that it cannot generate multiple instances of the same catalog item within a single submission. This is the key blocker for our use case.
The Solution: A Modern Approach π‘
We can solve this by combining a few powerful platform features: a Record Producer, a Multi-Row Variable Set (MRVS), and a Flow Designer Subflow that leverages the Cart API.
Hereβs the high-level workflow:
- Capture Data: The user enters multiple issues into an MRVS on a Record Producer form.
- Process Rows: After submission, a Subflow is triggered. It takes the MRVS data as input and iterates through each row.
- Build the Cart: For each row, the Subflow uses the CartJS API to add the corresponding catalog item to a new shopping cart.
- Place the Order: Once all items are in the cart, the Subflow places the order, generating a single REQ with multiple RITMs.
- Redirect User: The Subflow returns the new REQ's details to the Record Producer, which then redirects the user to their request summary page.
Step-by-Step Implementation Guide
Step 1: Create the User Interface
- Create a Record Producer: This will be the entry point for your users.
- Create a Multi-Row Variable Set (MRVS): Add all the common variables that your catalog items will need (e.g., action, issue_type, issue_id).
- Add the MRVS to the Record Producer: This allows the user to add as many rows (issues) as they need.
Step 2: Build the Logic Engine with a Subflow βοΈ
Create a Subflow in Flow Designer. This is where the magic happens!
- Input: Define a Subflow input of type JSON to receive the MRVS data from the Record Producer.
- Action: Add Items to Cart:
- Inside the Subflow, add a custom action step. This action will parse the input JSON and loop through each row.
- For each row, use the sn_sc.CartJS API to create a new cart and add items to it. This gives you full control over which catalog item to order and what variables to populate for each RITM.
- Action: Order cart: Once all the items have been added to the cart then order it using a custom action.
- Output: Define a Subflow output (e.g., request_details) to return the generated REQ number and sys_id as a JSON string.
Step 3: Connect the Producer to the Subflow
- Navigate to your Record Producer's configuration and open the Script section.
- In this server-side script, call the Subflow you created using sn_fd.FlowAPI.executeSubflow() OR use just copy paste subflow code snippet.
- Capture the output from the Subflow and use it to build a redirect URL, sending the user directly to their newly created request.
And that's it! You've successfully created a seamless, scalable, and user-friendly bulk-ordering system. π
- 80 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Great post! π
This is a very clear and well-thought-out solution to a common challenge in catalog design.
