# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
