# \_setPublic

Sets a User Filter to Private or Public, affecting whether all users can access it or not.

### Parameters

#### id

The ID of the User Filter.

#### val

An integer which sets the Public status of the User Filter:\
0 => Private\
1 => Public

### Examples

These examples use a created User Filter which has 105 as it's ID, and change it's name (represented by 'val') to "Test Filter" and "Tested Filter", respectively.

```
FM_api('UserFilter_setPublic',[
  'id'=>'30025',
  'val'=>'0'
  ]
);
```

### Results

#### On Success

This result will be given if running the function changes the User Filter's Public status:

```
{"ok":1}
```

This result will be given instead if the User Filter is already set to the Public status requested:

```
{"ok":1,"warning":"No change needed"}
```

#### On Failure

If the "id" parameter is less than 1 or does not have a given value:

```
{"error":"missing or invalid parameter: id"}
```

If the "id" parameter is given a value but it does not match the ID of an existing User Filter:

```
{"error":"filter with that ID does not exist"}
```

If the "val" parameter is not set or has a value higher than 1:

```
{"error":"missing or invalid parameter: val"}
```


---

# 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/userfilter/_setpublic.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.
