Custom Code Functions and Examples

  • this.allowSubmission(Boolean) :

A function that enables the submission of tasks based on boolean values “true” and” false".

Ex:

if (values["Field_check"] == "No") { let mandatoryFields = ["Field1", "Field2"] for (let field of mandatoryFields) { if (!values[field] || values[field] === "") { alert("Please fill field " + field) this.allowSubmission(false) break } } }

 

  • this.disAllowSubmit(Boolean)

A function that disables the submission of tasks based on boolean values “true” and” false".

Ex:

if (values["Field_check"] == "No") { let mandatoryFields = ["Field1", "Field2"] for (let field of mandatoryFields) { if (!values[field] || values[field] === "") { alert("Please fill field " + field) this.disAllowSubmit(true) break } } }

 

  • this.changeFormValue(field_name, new_value)

A function to assign a value to an output field, which can either be a new value or the value from another field.

Ex:

this.changeFormValue("field_name", inputValues["field_name_new"])(Assign value of an input field to any output field) or this.changeFormValue("field_name", values["field_name_new"])(assign a value from an output field to an output field) or this.changeFormValue("field_name", “Any value“)(Assign any string value to an output field)

 

  • this.changeInputValue(field_name, value)

A function to assign a value to an input field, which can either be a new value or the value from another field.

Ex:

 

  • this.enableField(field_name, Boolean)

A function that enables a field which was previously disabled

Ex :

 

  • this.disableField(field_name)

A function that disables a field that was previously enabled

Ex :

 

  • this.mandatoryField(field_name, Boolean)

A function that sets a field as mandatory or non-mandatory based on the boolean value, used to conditionally change the field's mandatory state. Ensure the field is not marked mandatory in the Task Design section of the project configuration. Use 'true' or 'false' to toggle the state.

Ex:

 

  • this.hideInputField(["field_name1", "field_name2"],"template_name")

A function used to conditionally hide input fields.

Ex:

 

  • this.unHideInputField(["field_name1", "field_name2"],"template_name")

A function used to conditionally unhide input fields that were previously hidden

Ex:

 

  • this.hideOutputField(["field_name1", "field_name2"],"template_name")

A function used to conditionally hide output fields.

Ex:

 

  • this.unHideOutputField(["field_name1", "field_name2"],"template_name")

A function used to conditionally unhide output fields that were previously hidden

Ex:

 

  • this.hideTemplateSection(["Template1", "Template2"])

A function used to conditionally display or hide templates. This can be highly effective when managing projects with numerous input and output fields. By grouping these fields based on a common theme, separate templates can be utilized to show relevant information only when needed, while hiding the rest. This approach helps reduce unnecessary scrolling and prevents accidental entries in fields that aren't currently required.

 

  • this.unhideTemplateSection(["Template1"])

A function used to unhide/display a hidden template.

 

  • this.hideUserBulkTaskButtons(["button 1 name", "button 2 name", …n])

A function used to conditionally hide task buttons in excel view/bulk task labelling UI.

 

  • this.unHideUserBulkTaskButtons(["button 1 name", "button 2 name", …n])

A function used to conditionally unhide task buttons that were previously hidden in excel view/bulk task labelling UI.

Ex:

 

  • this.changeAnnotationClasses(newClass).

A function to load classes for annotation projects using custom code.

Ex:

 

  • this.updateAnnotations(x)

A function that generates new annotations on load, updates existing annotations, or loads pre-annotations from an input field which is in JSON format.

Ex1: Generate 100 segments of transcription on load of a task

 

Ex3 : Load pre-annotations from an input field (when imported locally)

 

  • this.addNerPreRelRules(preRelRules)

A function to define rules in NER, specifying the starting and ending entities of a relation. Multiple relations can exist between two entities and can be defined as a comma separated list

Ex:

 

  • this.displayErrors(alertMessage)

A function used to display an error message when a specific condition is met.

Ex:

 

  • this.changeRowDataCC(rowData)

A function to write or update values in the sub-fields (line items) of Annotations for digitization projects.

Ex:

 

  • this.addToDropDown("fieldName",["value1",”value2”,...])

A function to add new values to an existing drop-down based on a condition.

Ex:

 

  • this.removeFromDropDown("fieldName",["value1",”value2”..])

A function to remove values to an existing drop-down based on a condition.

Ex:

 

  • this.removeAllFromDropdown("fieldName",[])

A function to remove all values from an existing drop-down

Ex:

 

  • this.updateLinkedChild("fieldname", "parentValue", ["childValue1","childValue2"....], ","add" / "delete"")

A function used to add or remove the possible value of linked Field Child based on selection of the parent possible values.

Ex:

 

  • values["field name"]

Used to retrieve values from any output field. This can be used to compare values between two output fields, assign the value of one field to another, or check a field's value and perform operations on other fields based on that value.

Ex:

 

  • oldValues["field_name"]

Used to access previous values of an output field in the on-change code, making it useful for determining whether a specific field's value has changed. This helps prevent unnecessary execution of a code block when the field value hasn't actually changed.

Ex:

 

  • inputValues[field_name]

It is used to access the values of input fields, enabling checks on specific field values and triggering operations on dependent fields. The value can also serve as a reference for other calculations or processes.

Ex:

Examples

  • To get current user id in a task

 

  • A code for audio transcription validation that ensures no special characters are allowed, while also validating tags and other criteria. This helps maintain transcription accuracy and consistency by enforcing proper formatting rules.

 

  • A code to load pre-annotations and class labels from YOLO data.

 

  • A code to track QC rejections using custom field.

 

  • A code to format the NER output to plain text and write to an output field.

 

  • Code to convert SRT to Taskmonk JSON and load pre-annotation for audio transcription.

 

  • On load custom code to convert gdrive sharing urls to viewing url.

 

  • Code to update all visible tasks based on changes in one task in Excel view.

 

  • Code to enable/disable fields in Excel View/Bulk tasks.

 

  • Code to write values into a Dynamic field on load

 

  • Code to map OCR-generated data to the attributes of a class, where the "notes" value is mapped to the "Value" attribute of the class.

 

  • Code to calculate IOU at level 3 for rejection logic

 

  • Code to add groups for image and video annotation projects