---
title: Remote proxy scripting examples
description: JavaScript scripting examples for querying, creating, and updating users through the PingIDM remote proxy
component: pingoneaic
page_id: pingoneaic:idm-objects:remote-proxy-scripting-examples
canonical_url: https://docs.pingidentity.com/pingoneaic/idm-objects/remote-proxy-scripting-examples.html
llms_txt: https://docs.pingidentity.com/pingoneaic/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
keywords: ["Data Object Model", "Synchronization"]
section_ids:
  remote-proxy-script-query: Query remote users
  remote-proxy-script-create: Create a user on the receiving tenant
  remote-proxy-script-update: Update a remote user
---

# Remote proxy scripting examples

After you've created a mapping, you can manage the receiving Advanced Identity Cloud tenant or PingIDM instance using a [script function](../idm-scripting/scripting-func-engine.html):

## Query remote users

```javascript
// Query users from receiving tenant
var remoteUsers = openidm.query(
  "external/idm/<receiving-tenant-name>/managed/realm-name_user",
  {
    "_queryFilter": "userName eq 'bjensen'"
  }
);

logger.info("Found {} remote users", remoteUsers.result.length);
```

## Create a user on the receiving tenant

```javascript
var newUser = openidm.create(
  "external/idm/<receiving-tenant-name>/managed/realm-name_user",
  null,
  {
    "userName": "jdoe",
    "givenName": "John",
    "sn": "Doe",
    "mail": "jdoe@example.com",
    "password": "<password>"
  }
);

logger.info("Created remote user: {}", newUser._id);
```

## Update a remote user

```javascript
var updatedUser = openidm.patch(
  "external/idm/<receiving-tenant-name>/managed/realm-name_user/95b2b43c-621e-4bca-8a97-efc768f17751",
  null,
  [
    {
      "operation": "replace",
      "field": "/mail",
      "value": "newemail@example.com"
    }
  ]
);
```
