MyChat Scripts: function mKanbanGetTaskNameByID — get the task name by ID
Get the Kanban project task name by its numeric ID.
Syntax
function mKanbanGetTaskNameByID(const iTaskID: integer): string;
Parameters and return values
Parameter |
Type |
Value |
iTaskID |
integer |
task ID, number. |
Function result
Task name, text string. If a number is incorrect or does not exist, the function returns an empty string.
Example
The example for automatic birthday congratulation. Congratulations are posted on announcements board, and the script deals with the event "User defined script"\ "Every hour".
// ---------------------------------------
// Script created by Oleksii Pikurov ([email protected])
// 18.01.2021 20:45:13
// ---------------------------------------
var
iUIN: integer;
dtExpired: double;
sUsersList, sUserFullName, sMsg, sGender, sToday: string;
begin
dtExpired := Now; // get current data
sToday := FormatDateTime('ddmmyyyy', dtExpired);
// if we have worked already, then do nothing
// to avoid repeated congratulations
if mDBStorageGetData('birthday-script') = sToday then exit
else mDBStorageSetData('birthday-script', sToday);
sUsersList := mGetBirthdayUsers(dtExpired); // get the list of people's UINs who have birthday today
while length(sUsersList) > 0 do begin
iUIN := StrToInt(Fetch(sUsersList, ','));
sUserFullName := mGetUserFullNameByPreset(iUIN, 0); // 0 — "John Doe"
if mGetUserAttribute(iUIN, 'Sex') = '2' then sGender := 'her' // get a user's gender
else sGender := 'his';
// create a congratulations line
sMsg := 'Today is' + sUserFullName + ' birthday!' +
CRLF +
'Congratulations ' + sGender + ' and best wishes ' +
'to you!';
// if today is a day off, then add days to Monday
case DayOfTheWeek(dtExpired) of
6: IncDay(dtExpired, 2);
7: IncDay(dtExpired, 1);
end;
// ...and post a congratulations on the bulletin board for all users
mAddNewBBSMessage(sMsg, dtExpired, false);
end;
end.
See also