project BLF > class PWorkInbox > method CreateMessage

Description

Create a new message


Parameters


icFrominputcharacterThe login who has sent this message.
icToinputcharacterThe user to which the message must be sent.
icCcinputcharacterThe comma separated list of users to which the message should be sent
icBccinputcharacterBlind copy
icSubjectinputcharacterThe subject of the message to be created.
icContentinputcharacterThe content of the message.
icGuidinputcharacterGuid for the external message.
If not passed, the guid is calculated by the method itself.
icContentTypeinputcharacterContent type:

Can be "text/plain" or "text/html". Default is "text/plain".
oiReturnStatusoutputintegerReturn status of the method.


Internal usage


BLF
method BSODLog.PostSave
method BWorkObject.PostSave


program code (program1/pworkinbox.p)

/* ================================================================= */
/*  Copy the input dataset to the right dataset expected by the      */
/*  backend.                                                         */
/* ================================================================= */

if icGuid = "" or icGuid = ?
then do :
    vaUuid = GENERATE-UUID.
    assign icGuid = GUID(vaUuid).
end.
if icContentType = "" or icContentType = ?
then assign icContentType = "text/html":U.

empty temp-table ttMessage.

assign vhIn = ?
       vhOut = ?
       vhInOut = dataset dsMessage:handle.

Create Dataset vhIn in widget-pool "non-persistent".
Create dataset vhOut in widget-pool "non-persistent".

create ttMessageQueue.
assign ttMessageQueue.queueName = "Inbox":U.

set-size(vmContent) = length(icContent,"RAW":U) + 1.
put-string(vmContent,1) = icContent.
create ttMessage.
assign ttMessage.msgGuid = icGuid
       ttMessage.msgParentGuid = "" 
       ttMessage.msgFrom = icFrom
       ttMessage.msgTo = icTo
       ttMessage.msgCc = icCc
       ttMessage.msgBcc = icBcc
       ttMessage.msgSubject = icSubject
       ttMessage.msgDateCreated = now
       ttMessage.msgContentType = icContentType.
/* Use copy-lob statement instead of a normal assign statement because it results
   in an unusable temp-table with OE version 10.1C01 */
copy-lob vmContent to ttMessage.msgContent.

<M-2 run CallStandAloneService
   (input  ? (icExternalProcedureDispatcher), 
    input  'com/qad/shell/inbox/UpdateMessages_a.p':U (icExternalProcedureService), 
    input  vhIn by-reference (izInput), 
    input-output vhInOut by-reference (bzInputOutput), 
    input-output vhOut by-reference (bzOutput), 
    output viFcReturnSuper (oiReturnStatus)) in PWorkInbox>

If viFcReturnSuper <> 0
Then Assign oiReturnStatus = viFcReturnSuper.
If viFcReturnSuper < 0
Then Return. 

finally:
    set-size(vmContent) = 0.
    if vhIn <> ?
    then delete object vhIn.
    if vhOut <> ?
    then delete object vhOut.
end finally.