Passing cc value to a script library function

Hello All,

I have an approve button & based on the status it sends emails so I call scrip library function to send mail. I have cc field with multiple values of Abbreviated names.

This is what I am struggling need your suggestions.

Dim ccto as variant or string tried both.

ccto = doc.Tx_CopiedTo

passing the value of ccto to the function.

I am getting error as type missmatch, if I pass only one value it works it do not work for multivalue field.

Any suggestions would be appreciated. Thanks in advance.

Subject: passing cc value to a script library function

Post your code here. However, generally, if you are assigning a value from a field to a string, you cannot assign it like that. ccto = doc.Tx_CopiedTo(0) would get the value and place it in the string variable ccto. The way you are doing it, you are trying to place a NotesItem in a string. To see this, turn on your LS debugger and step through the code and check the variable types. For multi-value fields, you would create a loop and loop through the field as if it were an array, and place the values in an array or in multiple variables. You can, however place an array or a string into a field with the syntax doc.Tx_CopiedTo = TheArray or Tx_CopiedTo = TheString.

Subject: RE: passing cc value to a script library function

Thank you for your response.Did run the script in debug mode in fact always do that.

Dim ccto As Variant

Set ccto = doc.GetItemValue(“Tx_CopiedTo”)

When it is declared as variant it gives me type mismatch while opening the form

So tried using

Dim ccto as string

ccto = doc.Tx_CopiedTo

also tried the line below

doc.Tx_CopiedTo = ccto

it does not give me error while opening the form and gives at newdoc.Tx_CopiedTo line.

Call SendMail( mail, rmgr, ccto, “”, sub, db.Title, sub, doc, linkt )

And tried

Call SendMail( mail, rmgr, newdoc.Tx_CopiedTo, “”, sub, db.Title, sub, doc, linkt )

In my prior codes I used the send mail without using the function which used to work fine.

Maildoc.Copyto = doc.Tx_CopiedTo

Doc & maildoc is declared in the beginning…

Any suggestions would be appreciated. Thanks in advance.

Subject: RE: passing cc value to a script library function

go back and look at my other post in more detail. The problem is that you are trying to assign doc.tx_CopiedTo to a string, and you cannot do this. You must assign doc.tx_CopiedTo(0) to the string like so:

ccto = doc.Tx_CopeidTo(0)

Subject: RE: passing cc value to a script library function

Thanks for response. I am sorry asking this again… Yes your right ccto = doc.Tx_CopeidTo(0) works. if i use (0) it will get only first value & the field has multiple values. How do i get all the values in the field. How do I make it dynamic arrray instead of (0),(1) etc.m

It is strange why I do not get it. Any suggestions would be appreciated. Please I am struggling with for almost a day and half.

I appreciate your response. Thanks in advance.

Subject: RE: passing cc value to a script library function

Thing of the multivalue field as an array.

Loop through the field using a for loop (ubound will get you the upper value) or using a forall loop.

so you would, for instance say:

dim upper as integer

upper = UBOUND(doc.filedname) - 1

'We subtract because the upperbound will be one above the number of items in the array.

dim dataArray(o to upper) as String

for x = 0 to upper

dataArray(x) = doc.fieldname(x)

next x

'then do whatever you need to with the array here.

Subject: RE: passing cc value to a script library function

Thanks for your response. Just now i have tested using found something intresting.Dim item As NotesItem

Set item = newdoc.GetFirstItem(“Tx_CopiedTo”)

Call mail.Send(False, item.Values)

This piece of code works when I trying to pass the value to my library function it gives me type mismatch.

Call SendBookmarkMail( mail, reqby, item.Values, “”, “Test”, db.Title, “Test”, doc, “”) 'type mismatch at values…

So even if I do dynamic array it might now let me pass to this function.

with the function

Sub SendMail( _

copyTo As NotesItem

Call mail.ReplaceItemValue( “CopyTo”, copyTo )

’ send the email)

Any suggestions would be appreciated. The other option is not use the function just code it in the button itself. Just want to use lib functions calls.

Any suggestions would be appreciated. Thanks in advance.

Subject: RE: passing cc value to a script library function

What does the function declaration look like? Also, do you need a function, or would a sub do? You only need a function if you plan to pass data back to the calling subroutine. Make sure that your function declaration is formatted the same as the function call. if you pass in a variant, a notesitem, a string, and a double, for instance, make sure that the function declaration has variables for all of these declared in the function statement and that they are defined as the appropriate type.

it looks like you are passing

a NotesDocument (mail)

a string (reqby)

an array (item.values)

an empty string

a string (test)

a string (db.title)

a string (test)

a NotesDocument (doc)

an empty string

examples:

Call sendBookmarkMail(mail, reqby, item.Values, “”, “Test”, db.Title, "Test, doc, “”)

Sub sendBookMarkMail(c as NotesDocument, d as String, e as Variant, f as String, g as String)

'work with the variables

end sub

If you needed to return data from the subroutine, you would use a Function instead and call it like so

a = sendBookmarkMail(mail, reqby, item.Values, “”, “Test”, db.Title, "Test, doc, “”)

'Where a is, in this case, a string variable

Function sendBookMarkMail(c as NotesDocument, d as String, e as Variant, f as String, g as String) as String

'work with the variables

'set the function name equal to the data to return. It will be placed in the variable a in the calling program. The datatype of the function must be the same as the datatype for the variable that holds the returned data.

sendBookmarkMail = datavariabletoreturn

End Function

Subject: RE: passing cc value to a script library function

Thanks for your response… I am sorry i was using a sub not function. I was using sub such as Sub sendmail ()

end sub