> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/maintenance-and-troubleshooting/legacy-workflows/s-doc-jobs-legacy/custom-mailing-labels.md).

# Custom Mailing Labels

The client is looking to create mailing labels for contacts that are related to another object. In this example, the contacts that are needed are related to Case.

{% hint style="warning" %}
As long as the object is related to Contact, this should work. There may need to be some additional tweaking, but this is a good start.
{% endhint %}

## Instructions

1. Create a lookup field on SDOC Jobs tied to the related object (Case).
2. The query will need to be updated from what is listed in the Mass Merge article. Note: You will need to update `contact__c` to the lookup field you created.

### Original Query:

```
SELECT name, mailingstreet,mailingcity, mailingstate, mailingpostalcode 
FROM contact WHERE id 
IN (select SDOC__Contact__c from SDOC__SDJob__c where ownerid = '{{!User.id}}')
```

### Updated Query:

```
SELECT contact.name
    ,contact.mailingstreet
    ,contact.mailingcity
    ,contact.mailingstate
    ,contact.mailingpostalcode
FROM case
WHERE id IN (select Case__c from SDOC__SDJob__c where ownerid = '{{!User.Id}}') 
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.sdocs.com/sdocs/maintenance-and-troubleshooting/legacy-workflows/s-doc-jobs-legacy/custom-mailing-labels.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
