spws
Version:
SharePoint Web Services Wrapper
59 lines (58 loc) • 2.43 kB
TypeScript
import { SpwsResponse, Item, Command, Method } from "../../../types";
/**
* Contains the specifics for the create update or delete operation.
*/
export type Methods = Method[];
/**
* The update list items result
*/
export type Result = {
command: Command;
errorCode: string;
errorText?: string;
ID: string;
item: Item;
status: "success" | "error";
values?: object;
};
export interface Operation extends SpwsResponse {
data: {
methods: Result[];
success: boolean | null;
};
}
/**
* Adds, deletes, or updates the specified items in a list on the current site.
* @param listName A string that contains the name of the list. It is recommended that you use the list GUID
* @param methods An array that contains one or more methods for adding, modifying, or deleting items
* @link https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-services/ms772668(v=office.12)
* @example
* ```
* // Create, update and delete
* const res = await updateListItems("Announcements", [
* { command: "New", values: { Title: "Hello World" } },
* { command: "Update", ID: "2", values: { Title: "Hello World" } },
* { command: "Delete", ID: "3" },
* ]);
* ```
*/
declare const updateListItems: (listName: string, methods: Methods, { batchSize, onBatchComplete, onError, webURL, allowLongFieldNames, }?: {
/** The maximum amount of updates that can be sent per web request. A batch size of 0 is Infinite */
batchSize?: number | undefined;
/** A callback function that is invoked when a batch is complete */
onBatchComplete?: ((batch: Operation & {
errors: Result[];
}) => void) | undefined;
/** Return (stop) or continue execution of the scripts if an error occurs */
onError?: "Return" | "Continue" | undefined;
/** The SharePoint webURL */
webURL?: string | undefined;
/** If true, the field names contained with values will not be trimmed to 32 characters.
* This allows field names that exceed 32 characters to be used.
* This is a rare use case where 2 or more fields share the exact same name for the first 32 characters. For example
* 1. ThisIsAExtremelyLongTextFieldNam
* 2. ThisIsAExtremelyLongTextFieldNam0
*/
allowLongFieldNames?: boolean | undefined;
}) => Promise<Operation[]>;
export default updateListItems;