Hard coded string to be made to bold - string

complete code is as below I am fetching the value and sending it in mail but value hard coded ISMS: need to be in bold.
Public Function CCC_GetISMS_Details( ByVal dbPwOHelperPwO As ISingleDbObject) As String
Dim scriptErrorBase As String = "Script Error [CCC_GetISMS_Details]"
Dim fkPwo As IForeignKey = dbPwOHelperPwO.GetFK("UID_PersonWantsOrg")
Dim orderDetail2 As String = String.Empty
Dim DetailStrg As New StringBuilder
'there is a related pwo
If Not fkPwo.IsEmpty Then
Dim pwo As ISingleDbObject = fkPwo.Create()
'orderDetail2 = pwo.GetValue("OrderDetail2").String
'User Story 9672 to fetch the right ISMS Group from request and send it in approval mail
orderDetail2 = pwo.ObjectWalker.GetValue("FK(CCC_UID_CSMGroup).GroupName")
If Not String.IsNullOrEmpty(orderDetail2) Then
DetailStrg.AppendLine(String.Format("ISMS: {0}",orderDetail2))
End If
Else
Throw New Exception(scriptErrorBase & " no related person want org record!")
End If
Return DetailStrg.ToString()
End Function

DetailStrg.AppendLine($"<b>ISMS:</b> {orderDetail2}")

Related

How to get the smtp email address located on the left of the "on behalf of" address

I would like to get the email address from the true contact that is sending the mailItem. I don't want the on behalf email address.
Is there a way to do that?
Outlook mailItem example
This is my code:
Function GetSenderSMTPAddress(ByRef olkMailItem As Outlook.MailItem) As String
Dim olkSender As AddressEntry
Set olkSender = olkMailItem.sender
GetSenderSMTPAddress = GetSMTPAddress(olkSender)
End Function
Function GetSMTPAddress(ByRef olkAddress As AddressEntry) As String
Dim smtpAddress As String: smtpAddress = olkAddress.Address
Dim olkExUser As ExchangeUser
If olkAddress.AddressEntryUserType = olExchangeUserAddressEntry Or _
olkAddress.AddressEntryUserType = olExchangeRemoteUserAddressEntry Then
Set olkExUser = olkAddress.GetExchangeUser
End If
If Not IsNull(olkExUser) Then
smtpAddress = olkExUser.PrimarySmtpAddress
End If
GetSMTPAddress = smtpAddress
End Function
I have answered my own question creating a recipient with the display name, getting the addressEntry from that recipient and using the function that I have already developed to get the smtp address for the given addressEntry.
See the next code:
Function GetSenderSMTPAddress(ByRef olkNS As outlook.Namespace, ByRef olkMailItem As outlook.MailItem) As String
Dim strSenderName As String
strSenderName = olkMailItem.SenderName
Dim olkRecipient As Recipient
Set olkRecipient = olkNS.CreateRecipient(strSenderName)
Dim olkAddressEntry As AddressEntry
Set olkAddressEntry = olkRecipient.AddressEntry
GetSenderSMTPAddress = GetSMTPAddress(olkAddressEntry)
End Function
Function GetSMTPAddress(ByRef olkAddress As AddressEntry) As String
Dim smtpAddress As String: smtpAddress = olkAddress.Address
Dim olkExUser As ExchangeUser
If olkAddress.AddressEntryUserType = olExchangeUserAddressEntry Or _
olkAddress.AddressEntryUserType = olExchangeRemoteUserAddressEntry Then
Set olkExUser = olkAddress.GetExchangeUser
End If
If Not IsNull(olkExUser) Then
smtpAddress = olkExUser.PrimarySmtpAddress
End If
GetSMTPAddress = smtpAddress
End Function
The SMTP address will most likely be set on the message as a MAPI property that you can access using MailItem.PropertyAccessor.GetProperty - take a look at PR_SENT_REPRESENTING_SMTP_ADDRESS_W (DASL name http://schemas.microsoft.com/mapi/proptag/0x5D02001F) and PidTagSenderSmtpAddress_W (DASL name http://schemas.microsoft.com/mapi/proptag/0x5D01001F) instead of using GetExchangeUser() - take a look at the message with OutlookSpy (I am its author) - click IMessage button.

Sending outlook mail using VB.NET in Visual Studio 2015

I am trying to make a birthday application to read data from CSV, match today's date with DOB in the CSV file and send email to the corresponding Outlook email Id in the CSV file. We will be sending mail to Outlook Email Id's only.
I have written the code to get email addresses to which I need to send the email and I have stored them in a list. The list is iterated through and Outlook despatches an email to each. When the code reaches OutlookMessage.Send() the application doesn't do anything. Any code above OutlookMessage.Send() including Console.WriteLine() statement works properly.
arrName stores the names of the people mentioned in the CSV, arrValue is an array to store the date of birth of person mentioned, and arrEmail stores the email address.
matchName is a list, storing names of matching people according to their DOB mentioned in the CSV. matchDOB is a list to store their DOBs, and matchEmail stores email addresses.
The CSV file contains 3 columns: Name, DOB, Email ID.
The last Console.WriteLine() statement after the OutlookMessage.Send() is not working, but the one before it is fine.
Imports System.IO
Imports Microsoft.VisualBasic.FileIO.TextFieldParser
Imports outlook = Microsoft.Office.Interop.Outlook
Module Module1
Sub Main()
Dim File1 As String = File.ReadAllText("C:\Users\Music\Excel1.csv")
Dim arrName() As String
Dim arrValue() As String
Dim arrEmail() As String
Dim matchName As New List(Of String)
Dim matchDOB As New List(Of String)
Dim matchEmail As New List(Of String)
Using ioReader As New FileIO.TextFieldParser("C:\Users\Music\Excel1.csv")
ioReader.TextFieldType = FileIO.FieldType.Delimited
ioReader.SetDelimiters(",")
While Not ioReader.EndOfData
Dim arrCurrentRow As String() = ioReader.ReadFields()
If arrName Is Nothing Then
ReDim Preserve arrName(0)
ReDim Preserve arrValue(0)
ReDim Preserve arrEmail(0)
arrName(0) = arrCurrentRow(0)
arrValue(0) = arrCurrentRow(1)
arrEmail(0) = arrCurrentRow(2)
Else
ReDim Preserve arrName(arrName.Length)
ReDim Preserve arrValue(arrValue.Length)
ReDim Preserve arrEmail(arrEmail.Length)
arrName((arrName.Length - 1)) = arrCurrentRow(0)
arrValue((arrValue.Length - 1)) = arrCurrentRow(1)
arrEmail((arrEmail.Length - 1)) = arrCurrentRow(2)
End If
End While
Dim regDate As Date = Date.Now()
Dim strDate As String = regDate.ToString("dd/MMM/yyyy")
Dim index As Integer = 0
For Each element As String In arrValue
Dim compCond As Integer = String.Compare(strDate, element)
If compCond = 0 Then
matchDOB.Add(element)
matchName.Add(arrName(index))
matchEmail.Add(arrEmail(index))
End If
index = index + 1
Next
End Using
Dim OutlookMessage As outlook.MailItem
Dim AppOutlook As New outlook.Application
Dim ind As Integer = 0
For Each matchDOB1 As String In matchDOB
Try
Console.WriteLine("Starting 1")
OutlookMessage = AppOutlook.CreateItem(outlook.OlItemType.olMailItem)
Dim Recipents As outlook.Recipients = OutlookMessage.Recipients
Recipents.Add(matchEmail(ind))
OutlookMessage.Subject = matchName(ind)
OutlookMessage.Body = matchDOB1
OutlookMessage.BodyFormat = outlook.OlBodyFormat.olFormatHTML
Console.WriteLine("Before Send")
OutlookMessage.Send()
Console.WriteLine("Email Sent For " + matchName(ind))
Catch ex As Exception
Console.WriteLine("Email Not Sent")
'MessageBox.Show("Mail could not be sent") 'if you dont want this message, simply delete this line
Finally
OutlookMessage = Nothing
AppOutlook = Nothing
ind = ind + 1
End Try
Next
Console.Read()
End Sub
End Module
If I replace OutlookMessage.Send() with OutlookMessage.Display() then the Console.WriteLine("Email Not Sent") gets printed.
Just the sending mail part is left.
The last Console.WriteLine does not work because you catch an exception and do not display it
Catch ex As Exception
'MessageBox.Show("Mail could not be sent") 'if you dont want this message, simply delete this line
So first, take a look at the exception raised.
My guess is: your Visual Studio is running as administrator and not your Outlook. Both must run as the same. So restart your Outlook as administrator, or run your VS without administrator privilege

CSV to XLSX VB.NET

enter image description hereenter image description hereI am just learning VB.NET and unfortunately I have been tasked with something I do not have a clue how to do.
I need to create a quick windows based application to export csv files into an XLSX file.
Yes, I know that other posts may have a similar topic however this one I believe is unique.
The CSV file will have 5 headers, `Line, Component, Picked, Placed and Missed. We have part numbers in column 2 that would be placed under Component. I am understanding from the powers that be, this file sums the total part numbers i.e. 0-5490045 and the line JUKI 3 and totals Picked, Placed and Missed parts. I have provided a sample rows below. First row is the csv formatted, the second is the output. I am not sure which loop would be best a FOR loop, WHILE loop etc. I am assuming I will need a loop of some sort to get through all the data in the csv file.
The only code I have opens the dialog box and allows for file selection and attempts to read into a datatable. I am attempting to get this working and then restructure some code.
Imports Spire.Xls
Imports System.Windows.Forms
Imports System.Data
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dialog As OpenFileDialog = New OpenFileDialog
dialog.Filter="CSV document(*.csv)|*.csv"
Dim result As DialogResult = dialog.ShowDialog
If(result=DialogResult.OK) Then
Dim csvFile As String = dialog.FileName
Dim workbook As Workbook = New Workbook
workbook.LoadFromFile(csvFile,",")
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim dt As DataTable=worksheet.ExportDataTable
Me.dataGridView1.DataSource=dt
End If
End Sub
End Class
JUKI 3 0-5490045 96 96 3
Line Component Picked Placed Missed
JUKI 3 0-5490045 99 96 3
I hate to make a suggestion and not show how it would work. Below is an example using a custom object called Machine to hold the data. This class is a bare minimum for an object and is only used as an example to get you started. It has some fields that will come in handy when looping thru the list to do your computations. It is also here you could add some custom functions/subs to help in some task that involves “Machine” objects. Also here you could add some compare functions which will enable you to sort among other things. After you put all this together you should end up with a list of valid Machine objects.
It is this list you could use to help you move on to the computing/removing duplicates part of your task. In the process of computing the data you could create a final list of Machine objects that you could use to export to excel with headers or display it to a DataGridView. Hope this helps.
Machine Class
Public Class Machine
Private name As String
Private partNumber As String
Private inventoryIn As Integer
Private inventoryOut As Integer
Private inventoryMissing As Integer
Public Sub New(inName As String, inPartNum As String, inInvIn As Integer, inInvOut As Integer, InInvMis As Integer)
name = inName
partNumber = inPartNum
inventoryIn = inInvIn
inventoryOut = inInvOut
inventoryMissing = InInvMis
End Sub
Property GetName As String
Get
Return name
End Get
Set(value As String)
name = value
End Set
End Property
Public Overrides Function ToString() As String
Return "Name: " + name + " #: " + partNumber + vbTab + " In:" + inventoryIn.ToString() + " Out:" + inventoryOut.ToString() + " Miss:" + inventoryMissing.ToString()
End Function
End Class
Now to your issue of reading the file
I did not use anything involving excel. Since you have a simple csv file we will use it. Also we will use the Machine class above. Using your open file dialog we get the name of the file to read. A variable partsList is created to hold the Machine objects created when reading the file. Then a for each loop goes through the list and displays the results in a text box on the form.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dialog As OpenFileDialog = New OpenFileDialog
dialog.Filter = "CSV document(*.csv)|*.csv"
Dim result As DialogResult = dialog.ShowDialog
If (result = DialogResult.OK) Then
Dim csvFile As String = dialog.FileName
Dim partsList As List(Of Machine) = ReadText(csvFile)
For Each curMac As Machine In partsList
TextBox1.AppendText(curMac.ToString() + Environment.NewLine)
Next
End If
End Sub
Function to read the csv file
Private Function ReadText(filePath As String) As List(Of Machine)
Dim fileReader As System.IO.StreamReader
Dim data As List(Of Machine) = New List(Of Machine)
fileReader = My.Computer.FileSystem.OpenTextFileReader(filePath)
Dim curline As String = ""
While (Not curline Is Nothing)
curline = fileReader.ReadLine()
'' need to check for valid data
'' if anything is invalid simply ignore it... i.e. your bad rows
'' keep in mind this will also ignore good rows that have a single piece of data bad
If (StringOK(curline)) Then
Dim newMac = GetMac(curline)
data.Add(newMac)
End If
End While
Return data
End Function
A couple of helper functions to validate the data
Private Function StringOK(inString As String) As Boolean
If (String.IsNullOrEmpty(inString)) Then
Return False
End If
Dim splitArray() As String = inString.Split(",")
Try
If ((String.IsNullOrEmpty(splitArray(0))) Or (String.IsNullOrEmpty(splitArray(1)))) Then
Return False
End If
Dim value As Integer
If ((Not Integer.TryParse(splitArray(2), value)) Or
(Not Integer.TryParse(splitArray(3), value)) Or
(Not Integer.TryParse(splitArray(4), value))) Then
Return False
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
Function GetMac(inString As String) As Machine
Dim splitArray() As String = inString.Split(",")
Dim value As Integer
Dim name As String = splitArray(0)
Dim number As String = splitArray(1)
Integer.TryParse(splitArray(2), value)
Dim invIn As Integer = value
Integer.TryParse(splitArray(3), value)
Dim invOut As Integer = value
Integer.TryParse(splitArray(4), value)
Dim invMis As Integer = value
Return New Machine(name, number, invIn, invOut, invMis)
End Function
If you are trying to accomplish how to import the data into a datatable below is a fast way of handling that. This will bring your whole csv into a datatable which you could then do logic on and create your xlsx file.
Friend Shared Function GetExcelFile(ByVal strFileName As String, ByVal strPath As String) As DataTable
Try
Dim dt As New DataTable
Dim ConStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";Extended Properties=""Text;HDR=Yes;FMT=Delimited\"""
Dim conn As New OleDb.OleDbConnection(ConStr)
Dim da As New OleDb.OleDbDataAdapter("Select * from " & strFileName, conn)
da.Fill(dt)
Return dt
Catch ex As Exception
Return Nothing
End Try
End Function

Problem saving value to document, via custom class, in querysave

I have written a small custom class to run an audit trail in Lotus Notes 8.5.2. I set the value of a NotesRichTextItem in my custom class and everything looks fine. When I drop out of my custom class, back into the Querysave and I check the Source.Document I can see the value fine. Once the querysave finishes (the line after my custom class call is End Sub) I check the document properties and the field is empty. I will include all code below, although the function called from my querysave is querySaveCheckValues (I pass in Source).
Custom class
Option Public
Option Declare
Public Class AuditTrail
REM boolean to audit all document items or use item list
Private includeAllItems As Boolean
Private currentDoc As NotesDocument
Private session As NotesSession
Private AUDIT_FIELD_LIST As String
Private AUDIT_FIELD As string
Private auditFieldList As NotesItem
Private postOpenValues List As String
Private auditField As NotesRichTextItem
Private MULTI_VALUE_SEPARATOR As String
'default message value insert strings
Private INSERT_FIELD_NAME As String
Private INSERT_OLD_VALUE As String
Private INSERT_NEW_VALUE As string
'message string defaults
Private DEFAULT_MESSAGE_CHANGE As String
'********** Sub new **********
Sub New(Source As NotesUIDocument)
dim currentDoc As NotesDocument
'put received uiDoc into NotesDocument
Set currentDoc = source.Document
REM set some class variables
setDefaultStrings
includeAllItems = True 'Details to all items on document
Set session = New NotesSession()
REM Check if the pre-defined audit field exists. If it doesn't we will audit all fields
If currentDoc.hasItem(AUDIT_FIELD_LIST) Then
'check if audit field list has at least one value
If UBound(currentDoc.GetItemValue(AUDIT_FIELD_LIST)) > 0 Then
includeAllItems = False
'assign field to NotesItem
Set auditFieldList = currentDoc.GetFirstItem(AUDIT_FIELD_LIST)
End If
End If
'get handle to audit field
If Source.Isnewdoc Then
Set auditField = New NotesRichTextItem(currentDoc, AUDIT_FIELD)
End If
Set auditField = currentDoc.GetFirstItem(AUDIT_FIELD)
End Sub
'********** collect values from current document **********
Function postOpenCollectValues(Source As NotesUIDocument)
Dim currentDoc As NotesDocument
Dim docItem As NotesItem
Dim fieldName As String
Dim fieldValue As String
Set currentDoc = Source.Document
If includeAllItems = False then
If Not auditFieldList Is Nothing Then
'list through values, find field and add to list
Dim i%
For i = 0 To UBound(auditFieldList.Values)
fieldName = auditFieldList.Values(i)
'look for item on document
If currentDoc.Hasitem(fieldName) Then
Set docItem = currentDoc.GetFirstItem(fieldName)
'check if item is multivalue
If UBound(docItem.Values) > 0 Then
fieldValue = Join(docItem.Values,MULTI_VALUE_SEPARATOR)
Else
fieldValue = docItem.Values(0)
End If
'convert value to string and put into list
postOpenValues(fieldName) = fieldValue
End If
Next
End If
End if
End Function
'********** Query save check to see if any values have changed **********
Function querySaveCheckValues(Source As NotesUIDocument)
Dim docItem As NotesItem
Dim fieldName As String
Dim oldValue, newValue As String
Set currentDoc = Source.Document
'Use list of fields generated during post open to save from etting errors when new fields
'are added to forms
ForAll x In postOpenValues
'eliminate mess if field has been removed from form
If currentDoc.hasItem(ListTag(x)) Then
Set docItem = currentDoc.GetFirstItem(ListTag(x))
fieldName = ListTag(x)
'compare old and new value
oldValue = x
If UBound(docItem.Values) > 0 Then
newValue = Join(docItem.Values,MULTI_VALUE_SEPARATOR)
Else
newValue = docItem.Values(0)
End If
Call me.compareValues(fieldName, CStr(oldValue), Newvalue)
End If
End ForAll
'make sure any changes added to audit field in backend and not overwriten
' Call Source.Refresh(true)
End Function
'********** Simple function to write lines to audit **********
Private Function writeAudit(message As String)
Dim tmpItem As NotesRichTextItem
Dim dateTime As New NotesDateTime(Now)
Dim nameItem As New NotesName(session.Username)
'take a copy of the current audit field content and blank audit
Set tmpItem = New NotesRichTextItem(currentDoc, "tmpAudit")
Call tmpItem.AppendRTItem(AuditField)
Call auditField.Remove()
'create a new audit field item and add new message
Set AuditField = New NotesRichTextItem(currentDoc, AUDIT_FIELD)
Call AuditField.AppendText(CStr(dateTime.LSLocalTime))
Call AuditField.AddTab(1)
Call AuditField.AppendText(nameItem.Abbreviated)
Call AuditField.AddTab(1)
Call AuditField.AppendText(message)
'append previous audit field content
Call AuditField.AppendRtItem(tmpItem)
Call tmpItem.remove()
End Function
'********** Function to compare single and multi values **********
Private Function compareValues(fieldName As String, oldValue As String, newValue As String)
Dim Message As String
'check for multi value
If InStr(oldValue,MULTI_VALUE_SEPARATOR) = 0 Then
'single value
If newValue <> oldValue Then
'prepare message
Message = prepareMessage(fieldName, oldValue, newValue, "CHANGE")
Call writeAudit(Message)
End If
End If
End Function
'********** Replace values in default message with old and new values **********
Private Function prepareMessage(fieldName As String, oldValue As String, newValue As String, messageType As String) As string
Dim tmpMessage As String
'case statement for type
Select Case messageType
Case "CHANGE"
tmpMessage = DEFAULT_MESSAGE_CHANGE
'replace default insert text with real field name
tmpMessage = Replace(tmpMessage,INSERT_FIELD_NAME,fieldName)
'old value
tmpMessage = Replace(tmpMessage,INSERT_OLD_VALUE,oldValue)
'new value
tmpMessage = Replace(tmpMessage,INSERT_NEW_VALUE,newValue)
End Select
prepareMessage = tmpMessage
Exit function
End Function
'********** Little function to setup our equivelant of constants **********
Private Function setDefaultStrings
AUDIT_FIELD_LIST = "auditFieldList" 'default audit field list name
AUDIT_FIELD = "AuditField" 'field used to store audit
MULTI_VALUE_SEPARATOR = "~" 'Used to combine and split values in a multi value item
'Default message insert strings
INSERT_FIELD_NAME = "%FIELDNAME%"
INSERT_OLD_VALUE = "%OLDVALUE%"
INSERT_NEW_VALUE = "%NEWVALUE%"
'Messages Strings
DEFAULT_MESSAGE_CHANGE = "Value of field '" & INSERT_FIELD_NAME & _
"' amended from '" & INSERT_OLD_VALUE & "' to '" & INSERT_NEW_VALUE & "'"
End Function
'********** handle error messages generated by this code **********
Private Function handleErrors
const DEFAULT_ERROR_MESSAGE = "Unable to write audit information - an error occured"
'if we have a handle on the audit field write an entry
If Not auditField Is Nothing Then
writeAudit(DEFAULT_ERROR_MESSAGE)
End If
End Function
End Class
I think your code would work if you move the call to your class to the PostSave event instead of QuerySave.
I'm basing that on the fact that you're altering the back-end document within the QuerySave event, and after that event runs it should overwrite the back-end document with the new values from the front-end. Just a hunch, though, as I haven't confirmed this is the case.

Using a lotus script to change data in a field.Want the data to be multi lined

Good day,
I'll start by saying I work for a small company and have no official training in
Notes everything I know I've learned buy trial and error & using other peoples codes.
Application: We have a purchase order database that has been running for a very long time and threw the ages people put in supplier names diffirently. Now I found a code that goes into the selected forms and changes the field values which is exactly what I need the only problem
is it's single line. The field I want to update have about 5 text lines (Company name, Tel No etc..) and the original programer put all off the info in one field.
Question: Is there a way in the script linked below how I can make each prompt input go into a diffirent line.I tried a few thing and I think I may be missing something obvious.(If I try chr(10);chLv all I get is either the 2 values next to each other or get them seperated by a comma)
`
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim session As New NotesSession
Dim prompt As String
Dim fieldName As String
Dim fieldValue As String
Dim dataTypes As Variant
Dim thisDataType As String
Dim fieldValues As Variant
Dim newFieldValues As Variant
Dim db As NotesDatabase
Dim coll As NotesDocumentCollection
Dim i As Integer
Dim doc As NotesDocument
Dim item As NotesItem
prompt = "Please enter the name of the field to be updated"
fieldName = ws.Prompt(3, "Enter Field Name", prompt, "")
If fieldName = "" Then Exit Sub
If Instr(fieldName, " ") <> 0 Then
prompt = "Error! Field Names can't have spaces!"
Msgbox prompt, 16, "Error"
Exit Sub
End If
prompt = "Please enter the new value. For multiple values, separate with a colon."
Value1 =ws.Prompt(3, "Enter Field Value", prompt, "")
Value2= ws.Prompt(3, "Enter Field Value", prompt, "")
Fieldvalue=value1 + Chr(10) +value2
Redim dataTypes(5) As String
dataTypes(0) = "Text"
dataTypes(1) = "Number"
dataTypes(2) = "Date"
dataTypes(3) = "Readers"
dataTypes(4) = "Authors"
dataTypes(5) = "DELETE THIS FIELD"
prompt = "Choose the data type of the value(s)"
thisDataType = ws.Prompt(4, "Choose Data Type", prompt, dataTypes(0), dataTypes)
If thisDataType = "" Then Exit Sub
Set db = session.CurrentDatabase
Set coll = db.UnprocessedDocuments
fieldValues = Evaluate({#Explode("} & fieldValue & {"; ":")})
Select Case thisDataType
Case dataTypes(0) : Redim newFieldValues(Ubound(fieldValues)) As String
Case dataTypes(1) : Redim newFieldValues(Ubound(fieldValues)) As Double
Case dataTypes(2) : Redim newFieldValues(Ubound(fieldValues)) As Variant
Case dataTypes(3) : Redim newFieldValues(Ubound(fieldValues)) As String
Case dataTypes(4) : Redim newFieldValues(Ubound(fieldValues)) As String
End Select
For i = Lbound(fieldValues) To Ubound(fieldValues)
Select Case thisDataType
Case dataTypes(0) : newFieldValues(i) = Trim(fieldValues(i))
Case dataTypes(1) : newFieldValues(i) = Val(fieldValues(i))
Case dataTypes(2) : newFieldValues(i) = Cdat(fieldValues(i))
Case dataTypes(3) : newFieldValues(i) = Trim(fieldValues(i))
Case dataTypes(4) : newFieldValues(i) = Trim(fieldValues(i))
End Select
Next
Set doc = coll.GetFirstDocument
While Not doc Is Nothing
If thisDataType = "DELETE THIS FIELD" Then
If doc.HasItem(fieldName) Then Call doc.RemoveItem(fieldName)
Else
Call doc.ReplaceItemValue(fieldName, newFieldValues)
If thisDataType = dataTypes(3) Or thisDataType = dataTypes(4) Then
Set item = doc.GetFirstItem(fieldName)
If thisDataType = dataTypes(3) Then item.IsReaders = True
If thisDataType = dataTypes(4) Then item.IsAuthors = True
End If
End If
Call doc.Save(True, False)
Set doc = coll.GetNextDocument(doc)
Wend
End Sub
'
Sorry for the long post but wasn't sure what is needed. First time posting for help but I'm scared I missed something opposite.
Francois
If you don't care that the values are not actually seperate, but are in fact a single string seperated by newlines, you could try evaluating Field fieldname:=#implode(fieldname, #newline) There was a bug (now fixed) in the java api where using java newline chars \n did not translate through to the stored value. Having the field set via evaluating an #formula was a workaround.
It's possible (?) that there is a platform specific issue to using Chr(10). Have you tried using Chr(13) & Chr(10)? You coudl also try evaluating #newline and using what that gives you.
To display the values in separate lines within a field you have to open the field properties and on the 3rd Tab make sure the option "Display separate values with" is set to "New Line".
On another note the split function in lotusscript is the equivalent to the #explode, so this line:
fieldValues = Evaluate({#Explode("} & fieldValue & {"; ":")})
can be modified to the following:
fieldValues = split(fieldValue, ":")
Hope that helps.

Resources