Post activities in bulk. Can be as simple as one activity on one casetype or as complex as multiple activities over multiple cases of different casetypes.
Array of activity objects
OptionalreturnResult: booleanreturn the result (e.g. resultForm and/or createdCase)
OptionalcommitBetweenTasks: booleanwhen set to true, no rollback will be performed on earlier activities in this transaction
//== Simple 1 activity on current case with 2 fields
API.v1.bulkPostActivity([{
activity: {
activityId: '1:4581:10033'
},
'case': {
cases: [API.v1.info.getGlobalCaseId()]
},
fields: [{
externalReference: 'start',
value: new Date()
}, {
externalReference: 'title',
value: 'Subject'
}
]
}
], false, false)
.then(function(result) {console.info('BulkPost Completed OK', result);})
.catch(function(error) {console.error('BulkPost Completed ERROR', error);})
//== Activity JSON options
{
"activity": {
"activityId": "1:6679:1"
//no problem if the activity was not found, perhaps form a different casetype
},
"case": {
"cases": ["1:6685:2", "1:6685:5"]
},
"fields": [{
//no problem if the formfield was not found - it could be the formfield for a different casetype
//note that the formfield should be unique for a given activity
"id": "1:6679:1", //formfield / casetype-attribute / platform-attribute - id / src / origin /
knownid
"value": "value 1"
}, {
"externalReference": "someReference", //external reference
"value": "value 2"
}
]
}, {
"activity": {
"tag": "tag123"
},
"case": {
"attributeId": "1:6679:1" //the attribute value of the case of the request meta
//an error is given if the attribute was not found on this case
},
"fields": []
}, {
"activity": {
"activityId": "1:6679:1"
},
"case": {
"datasetId": "1:6679:1",
"columnId": "1:6679:1" //optional if cases-dataset, if empty, we use the case if the row
//an error is given if the dataset or column was not found
}
//the entire fields array is optional
}
Promise
API.v1.checkRights('1:4581:5436', API.v1.info.getGlobalCaseId()).then(function(hasRights) {
if(hasRights) {
//== do what you have to do now you know the user has the right rights
} else {
//== do what you have to do now you know the user does not have the right rights
}
})
.catch(function(error){
console.error('Unable to check rights', error);
});
Retrieve a dataset, conditions / aggregation are available. See the Dataset class for more detailed documentation.
OptionalwidgetId: stringconst Dataset = API.v1.Dataset;
const Or = API.v1.Dataset.Or;
const And = API.v1.Dataset.And;
const Condition = API.v1.Dataset.Condition;
const dSet = API.v1.getDataset('datasetId', 'caseId', 'widgetId').useExternalReference();
const thisConditionList = And(
Condition('amount','>','100'),
Condition('Country','==','Netherlands'),
Or(
Condition('averageAge','!=','12'),
Condition('Country','==','Belgium')
)
);
//== Simple count
dSet.where(thisConditionList)
.aggregate('columnReference', 'count', 'amount')
.sort('amount')
.exec()
.then(...)
.catch(...);
//== Advanced, using all functions
dSet
.select('personColumn', 'genderColumn') // optional, select only a few columns
//== For aggregate datasets: Filter on unaggregated dataset with preFilter
.preFilter(And(Condition('personColumn','==','Person'), Condition('genderColumn','==','Male')))
.groupBy('cityColumn', 'City')
.groupBy('countryColumn', 'Country')
.aggregate('amountColumn', 'count', 'amount')
.aggregate('avgColumn', 'avg', 'averageAge')
.where(thisConditionList) //== Filter on aggregated part of th dataset
.sort('averageAge', 'desc')
.sort('City')
.sort('Country')
.limit(10)
.skip(5)
.exec()
.then(function ( dataset ) {
console.info('dataset', dataset);
dataset.rows.forEach(function ( row ) {
console.info('Row in dataset', row);
});
})
.catch(function ( error ) {
console.warn('dsError', error);
});
CaseId of the form
CaseId where the form should be retrieved from
Optionalwidget?: stringWidget's CaseId to check rights
CaseId of the picklist
CaseId where the form should be retrieved from
Optionalwidget?: stringWidget's CaseId to check rights
Retrieve the reference of a case.
Promise will return a string
CaseId of the template
CaseId on which the template will be requested (CaseData template parts in the template will use this Id)
OptionalactivityContext?: stringActivity context that will be used by activityMeta template parts
OptionalrightsCase?: stringThe rightsCase if the caseId where the widget is on differs from the caseId parameter.
OptionaltaskContext?: stringTask context that will be used by taskMeta template parts
The widget to use to check rights
Launch activity on-screen in a modal.
Activity Id or Task Id
Case Id
Options
Preload picklists.
Should widgets be refreshed after this activity has been completed?
Context for the form, can be accessed in form plugins.
Activity Id to perform
Case Id to perform activity on
Optionaloptions: { allowInBackground?: boolean; refreshWidgets?: boolean; silent?: boolean } = {}OptionalallowInBackground?: booleanallowInBackground is an option introduced for minimizable modals. In some cases, forms need to be closed before proceeding. When enabled, this option allows the activity to continue running in the background without prompting you to close the form.
OptionalrefreshWidgets?: booleanShould widgets be refreshed after this activity has been, default is true completed?
Optionalsilent?: booleanSuppress the error popup when an activity fails. This allows you to handle the error manually as needed.
Data that should be posted. e.g. {fieldId: value,...}
API.v1.postActivity('1:4581:1668', '1:4584:6', { refreshWidgets: true }, {"externalReference": "Value"})
.then(function(data) {
console.info('Activity completed', 'createdCase:', data.createdCase, 'resultFields:', data.returnResult);
})
.catch(function(error) { console.warn('ActivityError', error); });
Upload a single file
The file to upload. See https://developer.mozilla.org/en-US/docs/Web/API/File
A function which gets called on upload-progress. Signature: function(progress, fileSize, fileObject) {}.
//== get files from a <input type="file"></input> field.
const files = document.querySelector('input[type="file"]').files;
//== loop through files
for (let i = 0; i < files.length; i++) {
const file = files.item(i);
console.info('Starting upload of a file',file);
API.v1.uploadFile(file, function(progress, fileSize, fileObject) {
console.info('FileUpload#Progress', progress, fileSize, fileObject);
})
.then(function(fileInfo){
//== `fileInfo` is a json and can be used to submit in activities
console.info('File was upload with great succes', fileInfo);
})
.catch(function(error){
//== Something went wrong, `error` describes what is was.
console.error('Unable to upload. Reason:', error);
})
}
The API Class. An instance is available via the global API.v1 variable.
Example