> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# MoveTaskAfter

# Package: crm

# Namespace: Tasks

# Method link: https://dev.wix.com/docs/api-reference/crm/crm/tasks/move-task-after.md

## Permission Scopes:
Manage Tasks: SCOPE.DC-CRM.MANAGE-TASKS

## Introduction

Moves a task specified by ID to be placed after another task in the task display.

You can reposition a task to be first in the display by omitting `beforeTaskId`.

---

## REST API

### Schema

```
 Method: moveTaskAfter
 Description: Moves a task specified by GUID to be placed after another task in the task display.  You can reposition a task to be first in the display by omitting `beforeTaskId`.
 URL: https://www.wixapis.com/crm/tasks/v2/tasks/{taskId}/move-after
 Method: POST
 Method parameters:
   param name: beforeTaskId | type: beforeTaskId | description: The GUID of the task after which the moved task is positioned in the task display. If `beforeTaskId` is not specified, the moved task is positioned first in the task display.  | validation: format GUID
 Return type: MoveTaskAfterResponse
  EMPTY-OBJECT {}

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TASK_NOT_FOUND | Description: Couldn't find the task.


```

### Examples

### Move Task after
Change a task position in the tasks list

```curl
curl -X POST \
  'https://www.wixapis.com/crm/tasks/v2/tasks/4973f73a-40ef-11ee-be56-0242ac120002/move-after' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  --data-raw '
  {
    "filter": {
      "taskId": "4973f73a-40ef-11ee-be56-0242ac120002",
      "beforeTaskId": "fca1ab15-0576-4121-9de0-024f0b5743fd"
    },
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.crm.tasks.moveTaskAfter(taskId, options)
 Description: Moves a task specified by GUID to be placed after another task in the task display.  You can reposition a task to be first in the display by omitting `beforeTaskId`.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  taskId
 Method parameters: 
   param name: taskId | type: string | description: GUID of the task to move. | required: true | validation: format GUID
   param name: options | type: MoveTaskAfterOptions  none  
        - name: beforeTaskId | type: string | description: The GUID of the task after which the moved task is positioned in the task display. If `beforeTaskId` is not specified, the moved task is positioned first in the task display.  | validation: format GUID
 Return type: PROMISE<MoveTaskAfterResponse>
  EMPTY-OBJECT {}

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TASK_NOT_FOUND | Description: Couldn't find the task.


```

### Examples

### Move a task to the top of the display (with elevated permissions)
```javascript
import { tasks } from '@wix/crm';
import { auth } from '@wix/essentials';

/* Sample taskId value: 
 * '37c2c378-8085-4ef7-8a3e-6f341248e757'
 */

export async function myMoveTaskAfterFunction(taskId) {
  
  try {
    const elevatedMoveTaskAfter = auth.elevate(tasks.moveTaskAfter);
    await elevatedMoveTaskAfter(taskId);
  
    console.log('Moved task to top of display');
  } catch (error) {
    console.log(error);
    // Handle the error
  }   
}
```

### Move a task to the top of the display
```javascript
import { tasks } from '@wix/crm';

/* Sample taskId value: 
 * '37c2c378-8085-4ef7-8a3e-6f341248e757'
 */

export async function myMoveTaskAfterFunction(taskId) {
  
  try {
    await tasks.moveTaskAfter(taskId);
  
    console.log('Moved task to top of display');
  } catch (error) {
    console.log(error);
    // Handle the error
  }   
}
```

### Update the display order of tasks (with elevated permissions)
This function moves a specified task to be displayed after another task using the `moveTaskAfter()` function.

```javascript
import { tasks } from '@wix/crm';
import { auth } from '@wix/essentials';

/* Sample taskId value: 
* '37c2c378-8085-4ef7-8a3e-6f341248e757'
*
* Sample options value:
* {
*   beforeTaskId: '3a49f901-62d5-4ca2-a8e8-395c562a3f7b'
* }
*/

const elevatedMoveTaskAfter = auth.elevate(tasks.moveTaskAfter);

export async function myMoveTaskAfterFunction(taskId, options) {

  try {
    await elevatedMoveTaskAfter(taskId, options);

    console.log('Successfuly updated task display.');
  } catch (error) {
    console.log(error);
    // Handle the error
  }   
}
```

### Update the display order of tasks
This function moves a specified task to be displayed after another task using the `moveTaskAfter()` function.

```javascript

import { tasks } from '@wix/crm';

/* Sample taskId value: 
 * '37c2c378-8085-4ef7-8a3e-6f341248e757'
 *
 * Sample options value:
 * {
 *   beforeTaskId: '3a49f901-62d5-4ca2-a8e8-395c562a3f7b'
 * }
 */

export async function myMoveTaskAfterFunction(taskId, options) {

  try {
    await tasks.moveTaskAfter(taskId, options);

    console.log('Successfuly updated task display.');
  } catch (error) {
    console.log(error);
    // Handle the error
  }   
}

```

### moveTaskAfter (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { tasks } from '@wix/crm';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { tasks },
  // Include the auth strategy and host as relevant
});


async function moveTaskAfter(taskId,options) {
  const response = await myWixClient.tasks.moveTaskAfter(taskId,options);
};
```

---