Mail Template scripts

Hello! 

1IM 8.1

I need get XDateInserted from Department view in Mail Template. 

I wrote script: 

Public Function CCC_Department_Get_XDateInserted_1(ByVal dbDepartment As ISingleDbObject) As String
            Dim strLOGFileName = "C:\temp\logs\temp.txt"


            Dim obj As String = dbDepartment.GetValue("XDateInserted").ToString()

            VID_Write2Log(strLOGFileName, String.Format("{0}, ==> Date: {1}", Now.ToString(), obj))

            Return obj

        End Function

But I catch empty string. 

In the Mail Teplate I wrote: $Script(CCC_Department_Get_XDateInserted_1)$

Any ideas? 

Parents Reply Children
  • How can I passing dbDepartment for the script? 

  • I would not pass the whole ISingleDbObject, because it is unneeded overhead. Giving the UID of the department is enough as the object can be fetched in script as well.

    Public Function TK_GetXDateInsertDepartmet(ByVal UID_Dep As String) As DateTime

    Dim dep = Connection.Session.Source().Get("Department", UID_Dep)
    Return dep.GetValue("XDateInserted")

    End Function

  • Not working. 

    2019-12-02 10:43:32 +05:00 - \T-ONEIM-DB-4 - VI.JobService.JobComponents.MailComponent - 65b62e34-be4e-422b-a799-84fa1d70e08a: Errors occurred
        [810254] Could not find a script with the correct signature.
           at StdioProcessor.StdioProcessor._Execute(Job job)
           at VI.JobService.JobComponents.MailComponent.Activate(String task)
           at VI.JobService.JobComponents.MailComponent._SendRichMail()
           at VI.Mail.MailComposer.<Compose>d__5.MoveNext()
           at VI.Mail.MailComposer.Compose(IEntity richMail, MailParameters parameters)
           at VI.Mail.MailComposer._RenderMessageBody(MailTemplate template, MailBodyFormat bodyFormat, MailParameters parameters, MailMessage msg)
           at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator)
           at System.Text.RegularExpressions.RegexReplacement.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat)
           at VI.DB.Scripting.PlaceholderReplacer._Replace(Match m)
           at VI.Base.SyncActions.Do[T](Func`1 function)
           at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
           ---- Start of Inner Exception ----
           at VI.DB.Entities.EntityWalker.<GetRawAsync>d__21.MoveNext()
        Log written to Job_65b62e34-be4e-422b-a799-84fa1d70e08a_20191202_104330862.log