# \_list

Lists Stocks using several optional parameters

### Parameters

#### fields

Fetches requested aspects of Stock, through the use of\
several fields in an array:\
"name", "code", "in\_stock", "average\_cost", "price", "nominal\_code", "tax\_rate", "description", "notes", "id", "price\_bands"

#### supplier\_id

Condition which only fetches Stock that are from a Supplier with the given id

#### all

Condition which decides if archived Stocks should also be included.\
0 => No,\
1 => Yes

#### last\_edited

Condition which filters fetched Stock by only selecting from after the given date

### Examples

(In these examples, there are 3 total Stocks,\
Test Stock 2 is Archived, Test Stocks 2 and 3 have a supplier)

1.\
This example simply gathers the id and name of every non-archived Stock

```
FM_api(
    'Stocks_list',[
        'fields' => '["id","name"]'
    ]
);
```

2.\
This example will gather the ids and names of all Stock, included Archived, under a Supplier with the ID of 368157

```
FM_api(
    'Stocks_list',[
        'fields' => '["id","name"]',
        'all' => '1',
        'supplier_id' => '368157'
    ]
);
```

3.\
This example below will fetch the id, names and prices of Stock valid under the following conditions:\
Their supplier has the ID of 368157,\
The stock is not Archived,\
The stock has received changes since the time of 14:47:30 on the 12th of March 2023.

```
FM_api(
    'Stocks_list',[
        'fields' => '["id","name","price"]',
        'supplier_id' => '368157',
        'last_edited' => '2023-03-12 14:47:30',
        'all' => '0'
    ]
);
```

### Results

#### On Success

1. All non-archive Stock fetched. (Stocks 1 and 3)

```
[{"id":427418,"name":"Test Stock 1"},{"id":427419,"name":"Test Stock 3"}]
```

2. All Stock under a supplier with the ID of 368157. (Stocks 2 and 3)

```
[{"id":427417,"name":"Test Stock 2"},{"id":427419,"name":"Test Stock 3"}]
```

3. The Ids, names and prices of every non-Archived Stock which has been edited since 14:47:30 on the 12th of March 2023 and also has a supplier under the ID of 368157.\
   (Stocks 2 and 3 have been edited since that time, however Stock 2 is Archived,\
   therefore only Stock 3 is fetched)

```
[{"id":427419,"name":"Test Stock 3","price":"2.0000"}]
```


---

# 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://docs.fieldmotion.com/fieldmotion-api-docs/stocks/_list.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.
