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)
function create(
documentName: string,
component: dxForm,
params: {
onClick?: (dashboardDocumentSaveObject: DashboardDocumentSaveObject) => boolean,
components?: {
description?: dxHtmlEditor,
files?: FileSystemWidgetComponent
},
mappers?: {
postModel?: (
postModel: PostModel,
dashboardDocumentSaveObject: DashboardDocumentSaveObject,
params: { isDraftModel: boolean }
) => PostModel,
briefPostModel: (
briefPostModel: BriefPostModel,
dashboardDocumentSaveObject: DashboardDocumentSaveObject
) => BriefPostModel
},
postChangesOnFeed?: boolean,
allowDraft?: boolean,
openAfterCreation?: boolean,
icons?: {
save?: {
class?: string,
tooltip?: string
},
draft?: {
class?: string,
tooltip?: string
}
}
}):
Parameter | Type | Required | Defaults | Description |
---|---|---|---|---|
documentName | DocumentName | true | Document's type name | |
component | dxForm | true | Document data |
Basic Usage
SW.Document.create(SW.DocumentName.Job, workspaceContext.get('form'), {
allowDraft: false,
components: {
description: workspaceContext.get('description'),
files: workspaceContext.get('files')
},
postChangesOnFeed: false,
onClick: async (dashboardDocumentSaveObject) => {
SW.UI.Buttons.setAllEnabled(true);
e.component.option('text', 'SAVE');
e.component.option('icon', '');
e.component.option('disabled', false);
SW.UI.Alert.success('Changes Saved')
return true;
},
mappers: {
briefPostModel: async (briefPostModel, dashboardDocumentSaveObject) => {
var formData = dashboardDocumentSaveObject.Components.FormComponent.option('formData');
briefPostModel.Text = formData.Description
return briefPostModel
},
postModel: async (dashboardDocumentSaveObject) => {
let form = workspaceContext.get('form')
let formData = form.option('formData');
var executor = formData.ExecutorId;
if (SW.Utils.isValidGuid(executor)) {
dashboardDocumentSaveObject.Actions.Assignments = [
{
Assign: true,
UserId: executor,
AssignmentTypeId: "31169ed9-b84d-4e94-87d4-048130fbd053"
}
]
}
dashboardDocumentSaveObject.Actions.Document.Job.AgreedDateUtc = formData.AgreedDateUtc;
return dashboardDocumentSaveObject
}
}
})
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>;
Parameter | Type | Required | Defaults | Description |
---|---|---|---|---|
documentName | DocumentName | true | Document's type | |
documentIds | string[] | true | An array of document ids | |
userFieldName | string | true | User field name | |
valueType | string | true | Specify 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.