MoveFile

From TempusServa wiki
Revision as of 16:43, 15 December 2021 by Tvi (talk | contribs) (Created page with "== What it does == Moves a file from one document-field to another, on the same entity. Works between document-fields with and without signing. == How to invoke == Add the following snippet to the entity scripts.<syntaxhighlight lang="javascript"> let moveFile = (id) => { const params = new URLSearchParams(window.location.search) $.ajax({ url: "main", method: "GET", data: { "command": "dk.tempusserva.codeunit.common.MoveFile", "SagID": params.get("SagID")...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

What it does

Moves a file from one document-field to another, on the same entity.

Works between document-fields with and without signing.

How to invoke

Add the following snippet to the entity scripts.

let moveFile = (id) => {
	const params = new URLSearchParams(window.location.search)
	$.ajax({
		url: "main",
		method: "GET",
		data: {
			"command": "dk.tempusserva.codeunit.common.MoveFile",
			"SagID": params.get("SagID"),
			"DataID": params.get("DataID"),
			"FileID": id.split("_")[2],
			"FieldFrom": [FROM-FIELD-ID],
			"FieldTo": [TO-FIELD-ID],
		},
		success: (data) => {
			if (data == "File moved") {
				$(`#${id}`).find("td").last().html("Moved")
			} else {
				alert(data)
			}
		},
	})
}

$(() => {
	$("#VB_DATA_[FROM-FIELD-NAME] .tableFiles thead tr").append("<th></th>")
	$("#VB_DATA_[FROM-FIELD-NAME] .tableFiles tbody").find("tr").each((i,e) => {
		$(e).append(`<td><a href="#" class="moveFile">Move</a></td>`)
	})
	$(".moveFile").on("click", (e) => {
		moveFile($(e.currentTarget).parent().parent().attr("id"))
	})
})

Remember to change the three values:

  • [FROM-FIELD-NAME]
  • [FROM-FIELD-ID]
  • [TO-FIELD-ID]

Configuration

None

Developer info

  • Type: CodeunitPagecontent (raw)
  • Security: Requires session