Need to modify lotus script to parse more then one entry

The following code is parsing job numbers from a string, I've now made it so that there are more then one job number separated by " ; " how do I get all the job numbers and copy then to the subject line separated by brackets [  ]  I am also running into the issue that when I reply to these emails I get additional brackets without the job numbers...this is HOT!  Below is the format of what needs to be parsed, I need all the client numbers between the - and the |

ClientName, xxx  -1192:1192-G0001 | JobName; ClientName2, xxx2 - 1085:1085-P0001 | jobname; ClientName3, xxx3 - 1085:1085-P0002 | jobname
Query Send Code:
If source.Document.HasItem("ActionInProgress") Then
		source.Document.RemoveItem("ActionInProgress")
	End If
	If source.Document.CustomerJob(0) = "To file please select a job here" Then
	Else	
		'Messagebox "Modify Subject"
		CustomerName$ = Trim(Strleft(source.Document.customerjob(0),"-"))
		JobNumber$ = Trim(Strrightback(Strleftback(source.Document.customerjob(0),"|"),":"))
		If Instr(source.Document.subject(0)," [" & JobNumber$ & "]") = 0 Then
			Call source.FieldAppendText("Subject"," [" & JobNumber$ & "]")
		End If
		If Instr(source.Document.EnterCopyTo(0),"jobcorrespondence@dalinalaw.com]") = 0 Then
			Call source.FieldAppendText("EnterCopyTo",",JobCorrespondence@dalinalaw.com")
		End If
		Call Source.FieldSetText("Customer",CustomerName$)
	End If
End Sub

Open in new window

padillrrProject CoordinatorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sjef BosmanGroupware ConsultantCommented:
You could do this the ugly way, using the Split() function.

Suppose your string is in the variable s

1) Use the Split() function
   v= Split(s, ";") ' will explode s on the semicolons

2) loop through individual items in v
   Forall vi In v
      w= Split(vi, "|")

etc.

But, er, why is the string so complex, isn't it possible to have an easier string?
0
padillrrProject CoordinatorAuthor Commented:
Sorry working with legacy applications. Any way to look for all the colons and grab the numbers from the colon to the |  ???
0
Sjef BosmanGroupware ConsultantCommented:
There's another function that might help you out here: StrToken

StrToken(expression as STRING, delimiter as STRING, wordNumber as LONG, compMethod as INTEGER) as STRING

See the Designer Help Database.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

padillrrProject CoordinatorAuthor Commented:
Sounds like I can use that but how do I get it to pick up all the job numbers before the | and after the :
0
Sjef BosmanGroupware ConsultantCommented:
Come on, I know you can do this yourself!

s = "ClientName, xxx  -1192:1192-G0001 | JobName; ClientName2, xxx2 - 1085:1085-P0001 | jobname; ClientName3, xxx3 - 1085:1085-P0002 | jobname"

v= Split(s, ";") ' will explode s on the semicolons
Forall vi In v
   w= StrToken(StrToken(vi, " | ", 1), " - ", 2)
   ' w is the word you're looking for!
   Print w
End Forall
0
padillrrProject CoordinatorAuthor Commented:
Help This isn't working...
Sub Querysend(Source As Notesuidocument, Continue As Variant)
	'Check preference and Warn if subject is blank for a new memo
	If source.Document.EnableBlankSubject(0) <> "1" Then
		If source.document.Subject(0) = "" Then
			If Messagebox(warnTxt, MB_YESNO + MB_ICONQUESTION, warnTitle ) = IDNO Then 
				vSubjectBlankSend = False
				Source.GoToField("Subject")
				Call source.Refresh
				Call cMemoObject.SetActionInProgress(MEMO_ACTION_NONE)
				Call Source.Document.ReplaceItemValue("SaveOptions","0")
				cMemoObject. SendBlankSubject=False
				continue = False		
				Exit Sub
			Else
				vSubjectBlankSend = True
				cMemoObject. SendBlankSubject=True
			End If
		End If
	End If
	
	If source.Document.HasItem("ActionInProgress") Then
		source.Document.RemoveItem("ActionInProgress")
	End If
	If source.Document.CustomerJob(0) = "To file please select a job here" Then
	Else	
		'Messagebox "Modify Subject"
		
		v= Split(source.Document.customerjob(0), ";") 
		Forall vi In v
			JobNumber$= Strtoken(Strtoken(vi, " | ", 1), " - ", 2)  
			If Instr(source.Document.subject(0)," [" & JobNumber$ & "]") = 0 Then
				Call source.FieldAppendText("Subject"," [" & JobNumber$ & "]")
			End If
			If Instr(source.Document.EnterBlindCopyTo(0),"jobcorrespondence@dalinalaw.com]") = 0 Then
				Call source.FieldAppendText("EnterBlindCopyTo",",JobCorrespondence@dalinalaw.com")
			End If
			Call Source.FieldSetText("Customer",CustomerName$)
		End Forall			
	End If
End Sub

Open in new window

0
Sjef BosmanGroupware ConsultantCommented:
I'll look into this tomorrow. In the meantime, you could check with the debugger. To make debugging easier, use the following code:

                v= Split(source.Document.customerjob(0), ";")
                Forall vi In v
                        h$= Strtoken(vi, " | ", 1)
                        JobNumber$= Strtoken(h$, " - ", 2)  
                        If Instr(source.Document.subject(0)," [" & JobNumber$ & "]") = 0 Then
                                Call source.FieldAppendText("Subject"," [" & JobNumber$ & "]")
                        End If
                        If Instr(source.Document.EnterBlindCopyTo(0),"jobcorrespondence@dalinalaw.com]") = 0 Then
                                Call source.FieldAppendText("EnterBlindCopyTo",",JobCorrespondence@dalinalaw.com")
                        End If
                        Call Source.FieldSetText("Customer",CustomerName$)
                End Forall                      
 
0
padillrrProject CoordinatorAuthor Commented:
Got a little Closer but no cigar yet, I am still only grabbing the 1st job number, I've posted the code with a change to this line:   JobNumber$= Strtoken(h$, ":", 2) cahnged it from - to : and now I can get the job number only, but I am looking to grab all the job jumbers and append then to the Subject.
Sub Querysend(Source As Notesuidocument, Continue As Variant)
	'Check preference and Warn if subject is blank for a new memo
	If source.Document.EnableBlankSubject(0) <> "1" Then
		If source.document.Subject(0) = "" Then
			If Messagebox(warnTxt, MB_YESNO + MB_ICONQUESTION, warnTitle ) = IDNO Then 
				vSubjectBlankSend = False
				Source.GoToField("Subject")
				Call source.Refresh
				Call cMemoObject.SetActionInProgress(MEMO_ACTION_NONE)
				Call Source.Document.ReplaceItemValue("SaveOptions","0")
				cMemoObject. SendBlankSubject=False
				continue = False		
				Exit Sub
			Else
				vSubjectBlankSend = True
				cMemoObject. SendBlankSubject=True
			End If
		End If
	End If
	
	If source.Document.HasItem("ActionInProgress") Then
		source.Document.RemoveItem("ActionInProgress")
	End If
	If source.Document.CustomerJob(0) = "To file please select a job here" Then
	Else	
		'Messagebox "Modify Subject"
		
		v= Split(source.Document.customerjob(0), ";") 
		Forall vi In v
			h$= Strtoken(vi, " | ", 1)
			JobNumber$= Strtoken(h$, ":", 2)
			If Instr(source.Document.subject(0)," [" & JobNumber$ & "]") = 0 Then
				Call source.FieldAppendText("Subject"," [" & JobNumber$ & "]")
			End If
			If Instr(source.Document.EnterBlindCopyTo(0),"jobcorrespondence@dalinalaw.com]") = 0 Then
				Call source.FieldAppendText("EnterBlindCopyTo",",JobCorrespondence@dalinalaw.com")
			End If
			Call Source.FieldSetText("Customer",CustomerName$)
		End Forall  
	End If
End Sub

Open in new window

0
Sjef BosmanGroupware ConsultantCommented:
You've got your logic wrong...

            v= Split(source.Document.customerjob(0), ";")
            JobNumber$= ""
            Forall vi In v
                  h$= Strtoken(vi, " | ", 1)
                  If JobNumber$<>"" Then JobNumber$= JobNumber$ + "|" ' separator ??
                  JobNumber$= JobNumber$ + Strtoken(h$, ":", 2)
            End Forall  
            If Instr(source.Document.subject(0)," [" & JobNumber$ & "]") = 0 Then
                  Call source.FieldAppendText("Subject"," [" & JobNumber$ & "]")
            End If
            If Instr(source.Document.EnterBlindCopyTo(0),"jobcorrespondence@dalinalaw.com]") = 0 Then
                  Call source.FieldAppendText("EnterBlindCopyTo",",JobCorrespondence@dalinalaw.com")
            End If
            Call Source.FieldSetText("Customer",CustomerName$)

First you have to collect all jobnumbers, and only then you can use the result in your form.
0
padillrrProject CoordinatorAuthor Commented:
Still only getting the 1st job number on the subject line....
0
Sjef BosmanGroupware ConsultantCommented:
Use the Debugger and step through your code!!
0
padillrrProject CoordinatorAuthor Commented:
Ran it through the debugger several times, the code seems to be working except for when it splits the customerjob it only displays the 1st object, I can change the code: v= Split(source.Document.customerjob(0), ";") by changing the number I can grab the different job numbers but it won't return all the job numbers...I've looked at split on the designer help and can't find whats missing.
0
Sjef BosmanGroupware ConsultantCommented:
Aaaaahhhh.... There are multiple jobnumber INSIDE source.Document.customerjob ?? It is a multi-value field? or is it a single value field with a lot of semicolons between the values?

An example could be useful here.

Dim Source as NotesUIDocument
Dim doc As NotesDocument

Set doc= Source.document

' Field ABC, multi-value contains 2 values: v-one and v-two

' In the default case, the statement
   Print Source.FieldGetText("ABC")
' should print
'    v-one;v-two

' Now with doc, which is the same document but then the not-UI object:
   Print doc.GetItemValue("ABC")
' will print an error (most likely)
   Print doc.GetItemValue("ABC")(0)
' will print
'    v-one
   Print doc.GetItemValue("ABC")(1)
' will print
'    v-two
   Print doc.ABC(1)
' will also print
'    v-two

So, in your case, you might not even need to Split the jobnumber, if it's indeed in a multi-value field!
Try:
   v= source.Document.customerjob
   JobNumber$= ""
   Forall vi In v
         h$= Strtoken(vi, " | ", 1)
... etc.

The debugger could have shown you this. Did you look in the variables at the bottom? Did you look in Source, and/or in doc ?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
padillrrProject CoordinatorAuthor Commented:
Great Job Sjef, Thanks I've attached the final code that worked....

Sub Querysend(Source As Notesuidocument, Continue As Variant)
	'Check preference and Warn if subject is blank for a new memo
	If source.Document.EnableBlankSubject(0) <> "1" Then
		If source.document.Subject(0) = "" Then
			If Messagebox(warnTxt, MB_YESNO + MB_ICONQUESTION, warnTitle ) = IDNO Then 
				vSubjectBlankSend = False
				Source.GoToField("Subject")
				Call source.Refresh
				Call cMemoObject.SetActionInProgress(MEMO_ACTION_NONE)
				Call Source.Document.ReplaceItemValue("SaveOptions","0")
				cMemoObject. SendBlankSubject=False
				continue = False		
				Exit Sub
			Else
				vSubjectBlankSend = True
				cMemoObject. SendBlankSubject=True
			End If
		End If
	End If
	
	If source.Document.HasItem("ActionInProgress") Then
		source.Document.RemoveItem("ActionInProgress")
	End If
	If source.Document.CustomerJob(0) = "To file please select a job here" Then
	Else	
		'Messagebox "Modify Subject"
		
		'v= Split(source.Document.customerjob(0), ";") 
		v= source.Document.customerjob 
		JobNumber$= ""
		Forall vi In v
			h$= Strtoken(vi, " | ", 1)
			If JobNumber$<>"" Then JobNumber$= JobNumber$ + " * " ' 
			JobNumber$= JobNumber$ + Strtoken(h$, ":", 2)
		End Forall  
		If Instr(source.Document.subject(0)," [" & JobNumber$ & "]") = 0 Then
			Call source.FieldAppendText("Subject"," [" & JobNumber$ & "]")
		End If
		If Instr(source.Document.EnterBlindCopyTo(0),"jobcorrespondence@mail.com]") = 0 Then
			Call source.FieldAppendText("EnterBlindCopyTo",",JobCorrespondence@mail.com")
		End If
		Call Source.FieldSetText("Customer",CustomerName$)
		
	End If
End Sub

Open in new window

0
padillrrProject CoordinatorAuthor Commented:
You not only help but you teach, thanks! I've learned a lot from you through the years!
0
Sjef BosmanGroupware ConsultantCommented:
Brilliant! Thanks for the compliment :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.