Skip to main content

Document

With this namespace, you can quickly provide methods to manipulate documents.

The namespace Document provides to developers, methods to easily create, update, retrieve document data.

//accessing to Document methods
SW.Document.{methodName}

create

Description

This method can be used to create a new document.

Method(s)

1   declare function create(documentName: DocumentName, params: {draftData?: IDraftDocument} = {}): void;
ParameterTypeRequiredDefaultsDescription
documentNameDocumentNametrueDocument's type name
draftDataIDraftDocumentfalseDocument data

Basic Usage

SW.Document.create(SW.DocumentName.Job, {draftData: data});

getCustomFields

Description

This method can be used to get a custom user field from various documents.

Method(s)

1   declare function getCustomFields(   
2 documentName: DocumentName,
3 documentIds: string[],
4 userFieldName: string,
5 valueType: string
6 ): Promise<any>;
ParameterTypeRequiredDefaultsDescription
documentNameDocumentNametrueDocument's type
documentIdsstring[]trueAn array of document ids
userFieldNamestringtrueUser field name
valueTypestringtrueSpecify the value type of the document user field

Basic Usage

SW.Document.getCustomFields(
SW.DocumentName.Job,
["b983e9b5-b2b8-485f-8ff8-794463771bcc"],
"Default",
"string"
);

getLookup

Description

This method can be used to execute a document lookup.

Method(s)

1   declare function getLookup(
2 documentName: DocumentName,
3 options: string | {searchValue?: string, skip?: number, take?: number} = {}
4 ): Promise<any>
ParameterTypeRequiredDefaultsDescription
documentDocumentNametrueDocument type
optionsstringfalseDocument id or search, skip and take values

Basic Usage

SW.Document.getLookup(SW.DocumentName.Job, options);

setCustomFields

Description

This method can be used to set custom user fields in documents.

Method(s)

1   declare function setCustomFields(
2 documentName: DocumentName,
3 documentIds: string[],
4 documentUserFieldsValue: DocumentUserFieldValueModel[]
5 ): Promise<DocumentUserFieldValuesModel[]>
ParameterTypeRequiredDefaultsDescription
documentNameDocumentNametrueDocument's type
documentIdsstring[]trueAn array of document ids
documentUserFieldsValueDocumentUserFieldValueModel[]trueUser fields to set into the passed documents

Basic Usage

SW.Document.setCustomFields(
SW.DocumentName.Job,
["b1dd37dd-4633-4cc4-a418-0830d5e35638"],
[{ ColumnName: 'AddedOn', Value: false, ColumnDataTypeId: 0 }]
);

update

Description

This method can be used to update fields in a document.

Method(s)

1   declare function update(
2 documentName: DocumentName,
3 documentId: string,
4 fields: string[],
5 values: string[]
6 ): Promise<any>
ParameterTypeRequiredDefaultsDescription
documentNameDocumentNametrueDocument type
documentIdstringtrueDocument id
fieldsstring[]trueFields to update
valuesstring[]trueValues to update the fields

Basic Usage

SW.updateDocument(
SW.DocumentName.Job,
"b1dd37dd-4633-4cc4-a418-0830d5e35638",
['AgreedDateUtc'],
['2021-01-01']
);