MyChat Server event: OnKanbanTaskMove, moving the task between stages
An event, occurs when moving a task from one stage to another.
Event template
function OnKanbanTaskMove(iCID: int64; iUIN: integer; var sJSONData: string): boolean;
begin
// your own code
result := true;
end;
begin
end.
Input your code instead of the comment.
Parameter description
Parameter |
Type |
Value |
iCID |
int64 |
Connection ID of a client-sender, unique session ID in online structure of network connections to the server; |
iUIN |
integer |
unique ID of the command sender(number > 0); |
sJSONData |
string |
changeable parameter, content of the command as a text string JSON. |
Parameter sJSONData |
Type |
Value |
ID |
integer |
task ID number; |
IDStage |
integer |
stage ID (where to move a task), number. |
Return value
By default, the function must return "true", however, if you return "false", the comment will not place, and the application receives the error #0332. You can also edit JSON object by changing parameters.
Example
Intercept the event and notify a user with a private message in the chat.
const
// UIN of a user to notify
CI_USER_UIN = 6;
// from who
CI_USER_FROM = 3;
function OnKanbanTaskMove(iCID: int64; iUIN: integer; var sJSONData: string): boolean;
var
iTaskID, iStageID, iProjectID: integer;
sStageName, sProjectName, sTaskName, sMsg, sUserName: string;
begin
// get info from a JSON object
JSONGetInteger(sJSONData, 'ID', iTaskID);
JSONGetInteger(sJSONData, 'IDStage', iStageID);
// get project ID by stage number
iProjectID := mKanbanGetProjectIDByStageID(iStageID);
// get stage, project, and task names
sStageName := mKanbanGetStageNameByID(iStageID);
sProjectName := mKanbanGetProjectNameByID(iProjectID);
sTaskName := mKanbanGetTaskNameByID(iTaskID);
// displayed name of a user who moved a task
sUserName := mGetUserAttribute(iUIN, 'DisplayName');
// create a message text for a user
// about a moving event
sMsg := 'User ' + sUserName + ' moved task "' + sTaskName + '" in the project "' +
sProjectName + '" to the stage "' + sStageName + '"';
mSendPrivateMessage(CI_USER_FROM, CI_USER_UIN, sMsg, 1);
// skip the event for futher processing
result := true;
end;
begin
end.