Solved

Need to modify lotus  script to parse more then one entry

Posted on 2008-10-29
16
532 Views
Last Modified: 2013-12-18
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

0
Comment
Question by:padillrr
  • 8
  • 8
16 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22833364
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
 

Author Comment

by:padillrr
ID: 22833555
Sorry working with legacy applications. Any way to look for all the colons and grab the numbers from the colon to the |  ???
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22833755
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:padillrr
ID: 22834657
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22836027
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
 

Author Comment

by:padillrr
ID: 22836423
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22836717
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
 

Author Comment

by:padillrr
ID: 22836853
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22839073
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
 

Author Comment

by:padillrr
ID: 22842455
Still only getting the 1st job number on the subject line....
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22842511
Use the Debugger and step through your code!!
0
 

Author Comment

by:padillrr
ID: 22843245
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
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 300 total points
ID: 22843393
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
 

Author Comment

by:padillrr
ID: 22843532
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
 

Author Closing Comment

by:padillrr
ID: 31511263
You not only help but you teach, thanks! I've learned a lot from you through the years!
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 22843846
Brilliant! Thanks for the compliment :-)
0

Featured Post

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question