# Account credit request form

URL: https://docs.sparklayer.io/help/forms/account-credit-request-form

Build an account credit request form in SparkLayer Forms: customers pick a purchase and line items, give reasons and upload photos for your team to approve.

> **Quick summary**
>
> - This worked example builds a form where logged-in B2B customers request credit for items from a recent purchase. Reasons include damaged, missing or incorrect items, and quality or pricing issues.
> - You build it at **Forms** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/forms)) using a repeatable group, purchase data references, display logic, internal fields and workflows. Forms is only in the SparkLayer Dashboard, not in the SparkLayer Wholesale app in Shopify admin.
> - It relies on the logged-in customer, so test it on your store, not on the **Preview** tab.
> - The approval and decline automations need the Growth plan or above, as they use [workflows](https://docs.sparklayer.io/help/forms/workflows.md).

## What you'll build

Customers will:

1. Select a recent purchase.
2. Add one or more line items they want credit for.
3. Choose a reason for each line item.
4. Give extra details depending on the reason.
5. Upload photos or supporting files.
6. Submit the request for review.

Your team can then:

- Track the request's status and assign it to someone
- Approve or decline it, and record the approved credit amount
- Add internal notes
- Run actions when a request is approved or declined

## How it works

The credit request process:

1. **Customer picks items**: They choose a purchase, then each affected line item and a reason.
2. **Adds evidence**: Extra fields appear for the reason; they upload photos or files.
3. **Submits**: The request arrives as an entry and your team is notified.
4. **Team reviews**: Reviewers update internal fields and decide.
5. **Workflow acts**: Approve or decline: email the customer or send it to another system.

You can start simple, by collecting requests and notifying your team. Add automation later, such as approval buttons, applying credit to the customer's account automatically on approval, and sending data to other systems.

## Before you start

This form works best when customers are signed in before they open it. SparkLayer can then identify the customer and use their customer, purchase and customer group data.

Before you build, decide:

- **Which purchases** customers can choose from (which purchase or order data).
- **Which credit reasons** you support.
- **What evidence** each reason needs.
- **Who reviews** requests.
- **Whether customers get a confirmation** email.
- **What happens after approval or decline**, for example sending the request to your ERP, helpdesk, finance system or support team.

> **Test on your store, not in Preview**
>
> The form shows each customer their own purchases, so it needs a logged-in customer. The **Preview** tab has no customer, so it can't show the purchase options. Embed the form on a page of your store where the SparkLayer Core Script is loaded, and test it there. The page can be private or hidden at first.

## Create the form

1. In the SparkLayer Dashboard, go to **Forms** in the SparkLayer Dashboard ([open](https://app.sparklayer.io/forms)) and click **Start with a blank form**.
2. On the **Settings** tab, enter the **Form title** "Account Credit Request" and click **Save** in the save bar.
3. Go back to the **Form** tab to add fields.

## Add the customer fields

The customer fills in these fields. On the **Form** tab, add:

| Field | Type | Notes |
| --- | --- | --- |
| **Purchase** | Select | The purchase the request relates to. Required. |
| **Credit request items** | Group, with **Repeatable** on | Lets customers add several line items. Holds the fields below. |
| **Reason category** | Radio (or Select) | Inside the group. For example: Damaged, Missing, Incorrect item, Quality issue, Pricing issue, Other. Required. |
| **Line item** | Select | Inside the group. Options come from the selected purchase. Required. |
| **Quantity affected** | Number | Inside the group. Useful when only part of a line item needs credit. Required. |
| **Reason for credit request** | Long text | Inside the group. Lets the customer explain the issue. Required. |
| **Supporting files** | File upload | Inside the group. Photos, delivery notes or other evidence. |
| **Preferred resolution** | Radio (or Select) | Inside the group. Optional. For example: Credit note, Replacement, Contact me. |

To set up the repeatable group:

1. Add a **Group** field and name it **Credit request items**.
2. On its **Properties** tab, turn on **Repeatable**, so customers can add the group more than once.
3. Add the reason, line item, quantity, description, file upload and resolution fields inside the group.

A repeatable group suits this form because one purchase can have several items that need credit.

## Show the customer's purchases as options

The **Purchase** field takes its options from the customer's purchases, not from a list you type.

1. Select the **Purchase** field.
2. In **Options**, switch from **Manual** to **Data source**.
3. Click **Select data source...**. In the **Select a reference** picker, click **See advanced options** to see every source, not only the form's fields.
4. Open **SparkLayer** > **Purchasing** and click **Select** on **Entry Customer's Purchases** (the purchases for the SparkLayer customer associated with this entry).
5. Click the **Option label field** reference and choose a clear label, such as **Purchase Identifiers** > **Visible ID**.

**Entry Customer's Purchases** is already filtered to the signed-in customer. Don't use **Store's Purchases**, which lists orders from all customers.

## Show the purchase's line items as options

The **Line item** field then lists the items in the purchase the customer picked.

1. Select the **Line item** field inside the group.
2. In **Options**, switch to **Data source** and click **Select data source...**, then **See advanced options**.
3. Open **SparkLayer** > **Purchasing**.
4. Under **Specific Purchase by SparkLayer ID**, click **Reference** and **Select** your **Purchase** field.
5. Scroll down and click **Select** on **All Packages' Line Items** (line items from every package in this purchase).
6. Click the **Option label field** reference and choose a clear label, such as **Line item Identifiers** > **SKU**.

## Show extra questions for each reason (optional)

Use display logic so customers only see the fields that matter for their reason:

| Reason | Extra fields to show |
| --- | --- |
| Damaged item | Photo upload, damage description |
| Missing item | Missing quantity, delivery note upload |
| Incorrect item received | Expected item, item received, photo upload |
| Quality issue | Description, photo upload |
| Pricing issue | Expected price, explanation |
| Other | General explanation |

For example, to show **Supporting files** only for damaged items:

1. Select the **Supporting files** field.
2. Open the **Display logic** tab.
3. Under **Conditional display logic**, set **Field** to **Credit request items** > **Reason category**.
4. Set **Condition** to **Equals** and **Value** to `damaged`.

See [Conditional logic](https://docs.sparklayer.io/help/forms/conditional-logic.md) for more.

## Add validation

Check each request is complete before it reaches your team:

| Field | Validation |
| --- | --- |
| Purchase | Required |
| Line item | Required |
| Reason category | Required |
| Quantity affected | Required, greater than 0 |
| Reason for credit request | Required for "Other" or complex reasons |
| Supporting files | Required for damaged or quality issue requests |

Most fields only need to be required. Select the field and tick **Required** under **Basic properties** on the **Properties** tab. For anything more, such as "greater than 0", use the **Validation** tab. See [Validation rules](https://docs.sparklayer.io/help/forms/validation.md).

## Add internal review fields (optional)

To manage the review in SparkLayer, add [internal fields](https://docs.sparklayer.io/help/forms/setup.md#add-internal-fields): fields only your team sees, next to each entry in the Dashboard. Customers never see them. If you review credit requests in your ERP or another system, you may not need this.

On the **Internal fields** tab, add fields such as:

| Internal field | Type | Purpose |
| --- | --- | --- |
| **Review status** | Select | New, In review, Approved, Declined, Actioned. |
| **Assigned to** | Text or Select | Who's handling the request. |
| **Decision** | Select | Approved or declined. |
| **Approved credit amount** | Number | The amount the reviewer approves. |
| **Reviewer notes** | Long text | Internal comments. |
| **External reference ID** | Text | A ticket, ERP or finance system reference. |
| **Approve** button | Workflow trigger button | Starts the approval workflow. |
| **Decline** button | Workflow trigger button | Optional. Starts a decline workflow. |

This keeps the customer's form short while giving your team a structured place to record the review.

## Review a request

When a customer submits the form, the request appears as an [entry](https://docs.sparklayer.io/help/forms/entries.md). Your team opens it, reviews the answers and uploaded files, and updates the internal fields. A typical review:

1. Set **Review status** to **In review**.
2. Add reviewer notes.
3. Set a decision.
4. If approved, enter the approved credit amount.
5. Click **Approve** or **Decline**. A workflow handles the next action.

## Notify your team on submission

Add a workflow that emails your team for every new submission:

1. On the **Workflows** tab, click **Create workflow**.
2. Add the **Form submitted** trigger.
3. Add a **Send email** step to your team's address.

Forms made from a template already have one, called **Notification of submission**.

## Send the customer a confirmation (optional)

To email the customer as well, add a second **Send email** step to that workflow on the **Workflows** tab. See [Form workflows](https://docs.sparklayer.io/help/forms/workflows.md).

## Clear line items when the purchase changes (optional)

The line item options depend on the selected purchase. If a customer picks a purchase, chooses line items, then changes the purchase, the old line items stay selected. A workflow can clear them.

1. On the **Workflows** tab, add a workflow and name it "Reset credit items when purchase changes".
2. Click **+ Add Trigger**, choose **Answer updated** and set it to watch the **Purchase** field.
3. Add a **Clear answer** step and set its **Target reference** to **Credit request items**.

Reset credit items when purchase changes:

1. **Answer updated**: Watching Purchase.
2. **Clear answer**: Target: Credit request items.
3. **Customer chooses again**: They pick line items from the new purchase.

This is a good example of using a workflow to keep dependent fields accurate (see [Reset a dependent field](https://docs.sparklayer.io/help/forms/workflows.md#reset-a-dependent-field)).

## Approve requests

After review, a workflow can handle the next action, for example sending the approved request to another system, emailing the customer and updating the entry's status. Create a workflow called "Credit request approved". Use either the **Approve** button or the **Review status** field as the trigger.

### Option A: an internal button

| Part | Value |
| --- | --- |
| Trigger | **Internal button clicked**, on the **Approve** button |
| Step 1 | **Condition** |
| Step 2 | **API request** or **Send email** |
| Step 3 | **Update entry or row** |

### Option B: a status field

| Part | Value |
| --- | --- |
| Trigger | **Internal field updated**, watching **Review status** |
| Condition | **Review status** equals "Approved" |
| Step 1 | **API request** or **Send email** |
| Step 2 | **Update entry or row** |

### Common approval actions

Whichever trigger you use, the workflow can:

- Send the approved request to an ERP or finance system with an **API request** step
- Create a support ticket by calling an external API
- Email the customer
- Set **Review status** to "Actioned"
- Update the customer record with an **Update customer** step

## Decline requests

For a structured decline process, create a second workflow called "Credit request declined".

| Part | Value |
| --- | --- |
| Trigger | **Internal button clicked** (the **Decline** button), or **Internal field updated** |
| Condition | **Decision** equals "Declined" |
| Step 1 | **Send email** |
| Step 2 | **Update entry or row** |

Common decline actions are emailing the customer, setting **Review status** to "Declined", adding an internal note and storing the date the request was declined.

Keep the customer's message short and clear. If the request needs a personal explanation, ask the reviewer to write an internal note, and include it in the email.

## Send approved requests to another system (optional)

If your finance, ERP, helpdesk or support system accepts API requests, add an **API request** step after approval. A developer usually sets this step up, as they know what data your other system expects. The request can include:

- Customer details
- Purchase or order details
- The requested line items and reasons
- Uploaded file references
- The approved amount and reviewer notes
- A link to the entry
- The external reference ID

Build the request body in the template editor. Insert values with **+ Reference** rather than typing reference paths (see [Data references](https://docs.sparklayer.io/help/forms/data-references.md)). Use **+ Loop** to output each item in the **Credit request items** group, and **+ Condition** for conditional content.

**Example JSON template for your developer**

Here's an example JSON template. Your field IDs and the fields your system expects will differ:

```json
{
    "purchase_id": "{{sparklayer:purchases.purchases[purchase_identifiers.sparklayer={entry:current.answers.order_id}][0].purchase_identifiers.platform}}",
    "returns": [{% for item in {{entry:current.answers.returns}} %}
        {
            "sku": "{{item.sku}}",
            "quantity": "{{item.quantity}}",
            "reason": "{{item.reason}}",
            "images": [{% for img in item.images %}"{{img}}"{% if not forloop.Last %},{% endif %}{% endfor %}]
        }{% if not forloop.Last %},{% endif %}
{% endfor %}]
}
```

Each uploaded file's value is a SparkLayer file ID. Your system can fetch the files securely with the [Files API](https://docs.sparklayer.io/developers/api/files/get-bulk-files.md).

## Publish, embed and test

1. When the form, internal fields and workflows are ready, click **Publish** and include all three (see [Versions and publishing](https://docs.sparklayer.io/help/forms/versions.md)).
2. Decide where customers will find the form: on an account page, linked from an order or support page, or shared as a link with selected customers.
3. Add the form to your store with the options on the **Embed** tab. Use a page where the SparkLayer Core Script is loaded, and where customers can sign in and see the SparkLayer account and cart widgets. See [Embed and style a form](https://docs.sparklayer.io/help/forms/embedding-and-styling.md).

The **Preview** tab is less useful for this form, because it has no logged-in customer. For this and any other advanced form, test on your store.

### Testing checklist

- A **logged-in customer** can open the form.
- The **Purchase** field shows the expected purchases.
- The **Line item** field shows the selected purchase's line items.
- **Changing the purchase** clears previously selected line items.
- **Reason-specific fields** show and hide correctly.
- **Required fields** stop incomplete submissions.
- **File uploads** work.
- A submitted request **appears as an entry**.
- The right **internal fields** appear next to entries.
- **Submission notification** emails are sent.
- **Approval and decline workflows** run correctly.
- **API requests** send the expected data, if you use them.

If you use customer-specific purchase data, test with more than one customer account.

## Tips

- Keep the customer's form short: the purchase, affected line items, reason and evidence.
- Use a repeatable group for line items, so customers don't submit a separate form for each item.
- Use display logic for reason-specific questions, so extra fields only appear when needed.
- Use file uploads for evidence. Photos help most with damaged or quality-related requests.
- Keep admin-only statuses, notes and decisions in internal fields, never on the customer's form.
- Clear dependent fields when the field they depend on changes.
- Use workflows for notifications, approvals, API requests, status updates and other repeatable admin steps.
- Start simple: launch with manual review, then add API integrations later.
- Test with real customer accounts to check purchases and line items show as expected.
