Перейти к содержимому
Участник сообщества #32
Участник сообщества #32
17 дек. 2024 г., 06:59(изменён)
Решено
0
0

Формирование объекта сообщения

Из чата сообщества

Всем привет, подскажите пожалуйста, как при формирование объекта сообщения(это требуется для отложенной отправки) кодом, заполнять тело и заголовок и применять постановки <%=objDoc%>, Моя реализация

iNotificationId = 7449228331914333915;
oNotifType = tools.open_doc(iNotificationId).TopElem;
oRep = ArrayOptFirstElem(oNotifType.recipients);
oNotifTemp = tools.open_doc(oRep.notification_template_id).TopElem;

var docActNotif = tools.new_doc_by_name("active_notification");
docActNotif.BindToDb();
teDocActNotif = docActNotif.TopElem;

oRepActNotif = teDocActNotif.recipients.AddChild();
oRepActNotif.address = oRep.eval_str;

teDocActNotif.subject = oNotifTemp.subject;
teDocActNotif.notification_id=iNotificationId;
teDocActNotif.object_id=curObject.id;
teDocActNotif.body = oNotifTemp.body;
teDocActNotif.send_date=new Date;
teDocActNotif.is_custom=true;
teDocActNotif.status = 'active';
docActNotif.Save();
Участник сообщества
Участник сообщества17 дек. 2024 г., 07:49(изменён)
Решение

Вот пример моего рабочего кода notificationDoc = OpenNewDoc('x-local://wtv/wtv_active_notification.xmd');

notificationDoc.BindToDb();

notificationDocTE = notificationDoc.TopElem;

notificationDocTE.create_date = CurDate;
notificationDocTE.is_custom = 1;
notificationDocTE.status = "active";
notificationDocTE.sender.address = global_settings.settings.own_org.email;
notificationDocTE.date = CurDate;
notificationDocTE.send_date = CurDate;


if( _send_time != null && _send_time != '' && _send_time != undefined )
    notificationDocTE.send_date = OptDate(StrDate(notificationDocTE.send_date, false, false) + ' ' + _send_time, CurDate);

  
 try{

    if ( objDocIDParam != null && objDocIDParam != '' && objDocIDParam != undefined ){

        notificationDocTE.object_id = OptInt(objDocIDParam);
        objDoc = tools.open_doc(objDocIDParam).TopElem;

    }else{
        objDoc = null;
    }



    if ( textParam != null && textParam != '' && textParam != undefined ){
        Text = textParam;
    }else{
        Text = "";
    }


    if ( objDocSecIDParam != null && objDocSecIDParam != '' && objDocSecIDParam != undefined ){
        notificationDocTE.sec_object_id = OptInt(objDocSecIDParam);
        objDocSec = tools.open_doc(objDocSecIDParam).TopElem;
    }else{
        objDocSec = null;
    }


    TopElem = notificationDocTE;

}catch ( err ){
    alert(err)
}




sourceNotificationDocTE = undefined;

sourceNotificationDocTE = tools.open_doc(_notification_id).TopElem;

notificationDocTE.subject = EvalCodePage(sourceNotificationDocTE.subject);
notificationDocTE.body_type = sourceNotificationDocTE.body_type;
notificationDocTE.body = EvalCodePage(sourceNotificationDocTE.body);
Участник сообщества
Участник сообщества17 дек. 2024 г., 08:18(изменён)

TopElem шаблона уведомления

Чтобы ответить, необходимо войти в систему