> For the complete documentation index, see [llms.txt](https://docs.rishvi.co.uk/linnworks/llms.txt).
> Use it to discover all available pages before exploring further.

# Bill To Change Based on SubSource

Automatically update the billing address on selected Linnworks orders based on the order subsource and predefined billing address values.

Billing address details may need to be standardised or replaced for specific sales channels, marketplaces, or subsources. Updating these details manually can take time and may lead to inconsistent billing information across orders.

The *Macro* helps automate this process by checking the order subsource and applying predefined billing address values when a matching subsource is found.

This macro uses comma-separated parameter values, allowing multiple subsources and billing address profiles to be configured in one macro setup.

> Keep billing address information consistent by automatically updating order billing details based on the order subsource.

## **Configure the Macro**

Once the app is installed, you need to create a macro configuration so the system knows which macro to run and which billing address values should be applied for each subsource.

This setup can be adjusted anytime based on your operational requirements.

### **Steps to Configure**

<Tabs>
  <Tab title="Step 1">
    **Go to Apps > Macro Configuration and click + Add new configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779275829241-0yfwugotwoc-pasted-image-1779275823619.png?fm=auto&auto=compress%2Cformat" width="1368" height="568" alt="" priority={true} fetchPriority="high" />
  </Tab>

  <Tab title="Step 2">
    **Select the BillToChangeBasedonSubsource macro and click Create Configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277172854-1p9y97lwml7-pasted-image-1779277167379.png?fm=auto&auto=compress%2Cformat" width="1192" height="542" alt="" priority={true} fetchPriority="high" />

    This creates a new configuration where you can define the required parameter values.
  </Tab>

  <Tab title="Step 3">
    **In the Macro Configuration screen, add the configuration name and parameter values.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277193720-2aycigdjtw5-pasted-image-1779277188282.png?fm=auto&auto=compress%2Cformat" width="718" height="631" alt="" />

    Configure the required parameters, including:

    - **Subsource**

    - **EmailAddress**

    - **Address1**

    - **Address2**

    - **Address3**

    - **Town**

    - **Region**

    - **PostCode**

    - **Company**

    - **Country**

    <Callout kind="warning" collapsed="false">
      **Note:** These values are comma-separated lists. Each list must contain values in the same order so the correct billing address is applied to the matching subsource.
    </Callout>
  </Tab>

  <Tab title="Step 4">
    **Make sure to enable the macro to continue with the Rule Engine configuration.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277233494-v6mg1g8ez98-pasted-image-1779277229305.png?fm=auto&auto=compress%2Cformat" width="1488" height="38" alt="" />

    <Callout kind="warning" collapsed="false">
      **Note:** If the macro is not enabled, it will not appear in the **Action** value list when setting up the rule.
    </Callout>
  </Tab>

  <Tab title="Step 5">
    **Go to Orders > Rules engine and click + Add new rule.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277319239-kqob97xy2m-pasted-image-1779277313920.png?fm=auto&auto=compress%2Cformat" width="1536" height="680" alt="" />
  </Tab>

  <Tab title="Step 6">
    **Enter the rule name and click Create.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277359841-8jlz9wd0fmk-pasted-image-1779277350644.png?fm=auto&auto=compress%2Cformat" width="323" height="194" alt="" style="width: 323px; height: auto; cursor: pointer; margin: 0 auto;" />
  </Tab>

  <Tab title="Step 7">
    **Click Add new, select Condition, set the condition as required, and save it.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277381299-cqqpf44laew-pasted-image-1779277376606.png?fm=auto&auto=compress%2Cformat" width="1536" height="358" alt="" />

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277392844-bvgw0uwzpn8-pasted-image-1779277388732.png?fm=auto&auto=compress%2Cformat" width="642" height="410" alt="" style="width: 642px; height: auto; cursor: pointer; margin: 0 auto;" />

    Use conditions that target orders where the billing address should be replaced based on subsource.
  </Tab>

  <Tab title="Step 8">
  **Add the macro action and click Save.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277452862-6saftjkhq1c-pasted-image-1779277447454.png?fm=auto&auto=compress%2Cformat" width="720" height="134" alt="" style="width: 720px; height: auto; cursor: pointer; margin: 0 auto;" />

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277467597-59rv51cvzb2-pasted-image-1779277461166.png?fm=auto&auto=compress%2Cformat" width="652" height="258" alt="" style="width: 652px; height: auto; cursor: pointer; margin: 0 auto;" />

    In the **Add action** window, enter the **Action name**, for example:

    BillToChangeBasedonSubsource

    - Set **Action type** to:

      `Execute a macro`

    - In **Action value**, select:

      BillToChangeBasedonSubsource

    - Click **Save**

    <Callout kind="warning" collapsed="false">
      **Note:** If the macro is not enabled, it will not appear in the **Action** value list when setting up the rule.
    </Callout>
  </Tab>

  <Tab title="Step 9">
    **Review the saved rule setup.**

    <Image src="https://blob-cdn.documentation.ai/org-87fb0951-1e07-4f5d-a887-8a7327c7777d/doc-98941d2e-0032-424f-8414-3034ac5fa6ee/1779277522948-9f4177o0k24-pasted-image-1779277517384.png?fm=auto&auto=compress%2Cformat" width="1528" height="634" alt="" />

    - Verify the condition and action are connected correctly

    - Click **Save** in the bottom-right corner to save the rule
  </Tab>
</Tabs>

Billing address updates can be useful when specific subsources require predefined company, address, or contact details. This macro helps apply those values automatically when the order subsource matches a configured entry.

<Columns cols="2">
  <Card title="Reduce Manual Billing Updates" icon="alarm-check" horizontal="false" target="_self">
    Eliminates the need to manually edit billing address details on matching orders.
  </Card>

  <Card title="Update by Subsource" icon="boxes" horizontal="false" target="_self">
    Applies billing address values based on the order subsource.
  </Card>

  <Card title="Support Multiple Profiles" icon="bell" horizontal="false" target="_self">
    Allows multiple subsources and billing address values to be configured using comma-separated parameter lists.
  </Card>

  <Card title="Maintain Consistent Billing Details" icon="bar-chart-big-icon" horizontal="false" target="_self">
    Helps keep billing information consistent for specific sales channels or marketplace subsources.
  </Card>

  <Card title="Use Existing Customer Details" icon="lucide-fast-forward" horizontal="false" target="_self">
    Keeps the customer full name and phone number from the original shipping address.
  </Card>

  <Card title="Handle Optional Fields" icon="lucide-message-circle-x" horizontal="false" target="_self">
    Uses **NA** to clear fields that should not be populated in the updated billing address.
  </Card>
</Columns>

### How It Works

The macro checks the order subsource, finds the matching configured billing address profile, and updates the order billing address.

<Steps>
  <Step title="Step 1" icon="airplay-icon" title-type="p">
    The macro starts execution and writes **Macro Start** to the log.
  </Step>

  <Step title="Step 2" icon="airplay-icon" title-type="p">
    The macro splits each configured parameter into comma-separated lists.
  </Step>

  <Step title="Step 3" icon="airplay-icon" title-type="p">
    It retrieves the order using the provided **OrderId**.
  </Step>

  <Step title="Step 4" icon="airplay-icon" title-type="p">
    The macro checks whether the order subsource exists in the configured **Subsource** list.
  </Step>

  <Step title="Step 5" icon="airplay-icon" title-type="p">
    If a matching subsource is found, the macro uses the matching list index to build the updated billing address.
  </Step>

  <Step title="Step 6" icon="airplay-icon" title-type="p">
    For each billing address field, the macro applies the configured value unless the value is **NA**.
  </Step>

  <Step title="Step 7" icon="airplay-icon" title-type="p">
    If a configured value is **NA**, the macro sets that billing address field to an empty value.
  </Step>

  <Step title="Step 8" icon="airplay-icon" title-type="p">
    The macro keeps **FullName** and **PhoneNumber** from the order shipping address.
  </Step>

  <Step title="Step 9" icon="airplay-icon" title-type="p">
    The macro updates the order billing address using the Linnworks Orders API.
  </Step>

  <Step title="Step 10" icon="airplay-icon" title-type="p">
    The macro logs **Billing Address has been Updated** and writes **Macro Finished** when execution ends.
  </Step>
</Steps>

### **Usage of App**

This macro is designed to update a single order billing address when executed by the Rule Engine. It is useful when billing address details need to be replaced for specific order subsources.

<Card title="OrderId" horizontal="false" target="_self">
  Defines the Linnworks order ID that should be processed.
</Card>

<Card title="Subsource" horizontal="false" target="_self">
  Defines the comma-separated list of order subsources that should trigger billing address updates.
</Card>

<Card title="EmailAddress" horizontal="false" target="_self">
  Defines the billing email address values. Each value must align with the matching subsource position.
</Card>

<Card title="Address1" horizontal="false" target="_self">
  Defines the first billing address line values.
</Card>

<Card title="Address2" horizontal="false" target="_self">
  Defines the second billing address line values.
</Card>

<Card title="Address3" horizontal="false" target="_self">
  Defines the third billing address line values.
</Card>

<Card title="Town" horizontal="false" target="_self">
  Defines the billing town values.
</Card>

<Card title="Region" horizontal="false" target="_self">
  Defines the billing region values.
</Card>

<Card title="PostCode" horizontal="false" target="_self">
  Defines the billing postcode values.
</Card>

<Card title="Company" horizontal="false" target="_self">
  Defines the billing company values.
</Card>

<Card title="Country" horizontal="false" target="_self">
  Defines the billing country values.
</Card>

<Card title="NA Field Behaviour" horizontal="false" target="_self">
  When a configured value is **NA**, the macro sets the corresponding billing address field to blank.
</Card>

<Card title="Execution Logging" horizontal="false" target="_self">
  The macro records start, billing update confirmation, errors, and completion status using the macro logger.
</Card>

### **Key Points to Remember**

- The macro processes one **OrderId**

- The macro is intended to run from the Rule Engine

- Billing address values are selected based on the order **SubSource**

- All parameter lists are split by commas

- Parameter values must be entered in matching order across all lists

- The macro uses the matching subsource index to select the correct billing values

- A value of **NA** is converted to an empty field

- **FullName** is copied from the shipping address full name

- **PhoneNumber** is copied from the shipping address phone number

- **Continent** is set to blank

- The macro logs when the billing address has been updated

- The macro code calls the billing address update when the order is found

<Callout kind="warning" collapsed="false">
  **Important:** Make sure all comma-separated parameter lists contain the same number of values. If the lists are not aligned, the macro may apply incorrect billing details or fail when reading a missing list value.
</Callout>

<Callout kind="warning" collapsed="false">
  **Important:** Configure the Rule Engine carefully so the macro only runs on orders with matching subsources. In the provided code, the billing address update call runs when the order is found.
</Callout>

### **What You Can Expect**

- **Billing address is updated for matching subsources**\
  When the order subsource matches a configured value, the macro applies the corresponding billing address profile.

- **Configured NA values are cleared**\
  Any field configured as **NA** is saved as blank.

- **Customer name and phone are retained**\
  The macro copies the full name and phone number from the shipping address.

- **Multiple subsources can be configured**\
  Comma-separated lists allow several subsource-to-address mappings in one configuration.

- **Execution is logged**\
  The macro records when it starts, finishes, and if an error occurs.

### **Overall Impact**

This macro improves billing address consistency by automatically applying predefined billing details based on order subsource. It reduces manual edits and helps ensure orders from specific subsources use the correct billing information.

### What To Do After the Macro Runs

After the macro has completed, review the processed order if needed to confirm that the billing address was updated correctly.

### **Steps to Follow**

<Steps>
  <Step title="Step 1" title-type="p">
    Open Linnworks and locate the order processed by the rule.
  </Step>

  <Step title="Step 2" title-type="p">
    Open the order customer or billing address details.
  </Step>

  <Step title="Step 3" title-type="p">
    Confirm that the order subsource matches one of the configured **Subsource** values.
  </Step>

  <Step title="Step 4" title-type="p">
    Confirm that the billing address fields match the configured values for that subsource.
  </Step>

  <Step title="Step 5" title-type="p">
    Continue with normal order validation, fulfilment, invoicing, or dispatch processing.
  </Step>
</Steps>

### **Why This Matters**

Keeping billing details consistent helps:

- Reduce manual billing address edits

- Apply correct billing information by subsource

- Improve order data consistency

- Support invoice or dispatch workflows

- Reduce errors caused by incorrect billing address values

### Best Practices

To get the most value from this macro, configure all parameter lists carefully and test with sample orders.

### **Recommended Guidelines**

- **Keep parameter lists aligned**\
  Every comma-separated list should have the same number of values and follow the same order as **Subsource**.

- **Use NA intentionally**\
  Use **NA** only when the field should be saved as blank.

- **Avoid commas inside address values**\
  Since the macro splits values by comma, avoid using commas inside individual address fields.

- **Use clear rule conditions**\
  Configure the Rule Engine so the macro runs only for orders that should receive billing address updates.

- **Test with one subsource first**\
  Confirm the billing address updates correctly before adding multiple subsource mappings.

- **Review billing address after setup**\
  Check sample orders to ensure the correct index mapping is being applied.

### **Troubleshooting**

<Card title="Billing address did not update as expected" horizontal="false" target="_self">
  Confirm that the order subsource exactly matches one of the configured **Subsource** values.
</Card>

<Card title="Wrong billing details were applied" horizontal="false" target="_self">
  Check that all comma-separated parameter lists are in the same order and contain the same number of values.
</Card>

<Card title="Field was saved blank" horizontal="false" target="_self">
  Check whether the configured value for that field is **NA**. The macro converts **NA** to an empty value.
</Card>

<Card title="Macro is not visible in the Rule Engine" horizontal="false" target="_self">
  Confirm that the macro configuration has been created and enabled in **Apps > Macro Configuration**.
</Card>

<Card title="Macro error occurred" horizontal="false" target="_self">
  Review the macro logs. Errors may occur if parameter lists are not aligned or a required list value is missing.
</Card>

<Card title="Subsource does not match" horizontal="false" target="_self">
  Confirm the spelling and spacing of the configured **Subsource** value matches the order subsource exactly.
</Card>

### **Summary**

The* Macro* updates the billing address on a Linnworks order based on the order subsource. It uses comma-separated configuration values to map each subsource to a predefined billing address profile.

This helps reduce manual updates, improve billing consistency, and ensure orders from specific subsources use the correct billing details.
