# autoCast

This method allows you to cast any value to the appropriate type in Java for the property passed in. The `entity` argument can be the entity name or an entity object.

## Returns

* This function returns the value casted to the right Java type

## Arguments

| Key          | Type   | Required | Default | Description                      |
| ------------ | ------ | -------- | ------- | -------------------------------- |
| entity       | string | Yes      |         | The entity name or entity object |
| propertyName | string | Yes      |         | The property name                |
| value        | any    | Yes      |         | The property value               |

## Examples

```javascript
baseService.autoCast( "User", "createdDate", arguments.myDate );
```


---

# 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://coldbox-orm.ortusbooks.com/v2.x-2/base-orm-service-1/service-methods/utility-methods/autocast.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.
