Improve company productivity with a Business Account.Sign Up

x
?
Solved

Deleting the value of an array if the reviewer click the reviewed  button

Posted on 2004-09-16
12
Medium Priority
?
206 Views
Last Modified: 2013-12-18


i have a multi value field that contain the list of all reviewer,

i want to delete the name of the reviewer on that list if they click the reviewed button i try this code but it didnt work

please check what is wrong on this code.

the field name is "SegReviewers"  multi value field


Sub Click(Source As Button)
      Dim session As New NotesSession
      Dim user As Variant
      
      Dim ws As New notesuiworkspace
      Dim Source2 As notesuidocument
      Dim curdoc As notesdocument
      Set Source2=ws.currentdocument
      Set curdoc=Source2.document
      
      Dim tmpnum As String
      Dim tmpname As String
      
      user = session.CommonUserName
      
      
      Call curdoc.ReplaceItemValue("SegReviewer",removeElement2(curdoc.SegReviewer,user))
      
      Call source2.Save
      
      Call source2.Refresh
      
      ans=Msgbox("Send to System File Admin for Verification."+_
      Chr(13)+Chr(13)+"Continue?",4+32+0+0,"Save")
      If ans=6 Then
            Call source2.FieldSetText("tmpstatus","Processing")
            Call source2.FieldSetText("StatusNum","2")
            Call source2.refresh      
            
            Call source2.FieldSetText("InSave","1")
            Call UpdateEditHistory(source2.document, "Send To File Administrator", "")
            Call sendnotification(source2.Document,2,tmpname,2)
            
            Call source2.Save
            Call source2.Refresh(True)
      End If
      'Call source2.close
      
End Sub

--------------------------------


function


Function removeElement2(varFromList As Variant,varTarget As Variant) As Variant
'removes an element from a list or array
      Redim arrReturn(0) As String
      Dim intCount As Integer
      
      intCount=0
      Forall varElement In varFromList
            If varElement<>varTarget Then
                  Redim Preserve arrReturn(intCount) As String
                  arrReturn(intCount)=varElement
                  intCount=intCount+1
            End If
      End Forall
      removeElement2=arrReturn
End Function









0
Comment
Question by:lovemeto
12 Comments
 
LVL 19

Expert Comment

by:madheeswar
ID: 12081419
it can be done through ArrayReplace
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12081452
this is a sample code:
Dim curitem As notesitem
Set curitem=curdoc.getfirstitem("leavelistdates_x") ' from current open document
vValues = fetdoc.GetItemValue ( "leavelistdates_x" ) 'is a multivalue
'and then replace the values with:
Call fetdoc.ReplaceItemValue( "leavelistdates_x" , Fulltrim ( Arrayreplace ( vValues , curitem.values , "" ) ) )

fetdoc is from another view.
it replace with "" and u can trim it further.

Look help for Arrayreplace.
0
 

Author Comment

by:lovemeto
ID: 12081642
thanks for quick response!
what do you mean by fetdoc is from another view?


you mean i need to create a view?

thanks
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LVL 19

Expert Comment

by:madheeswar
ID: 12081659
no need . that is for ur understanding
0
 
LVL 13

Expert Comment

by:CRAK
ID: 12082032
Isn't ArrayReplace somewhat buggy?
Never tried it in R6, but we have abandoned use of it in R5 as it sometimes doesn't work as expected.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12082118
I never faced this problem in R5.I have used in really busy database. I heared it is bugy , but if it working fine for me. Else we need to have to loops and big performance draw back in another (ofcourse which lovemoto) has done.
0
 

Author Comment

by:lovemeto
ID: 12082534
please give more more idea,

my field is "segreviewer"  a multi value field that contain all reviewers,

my criteria is session.CommonUserName if the current user is listed on  the segreviewers field if they click Reviewed button they will authomatically deleted to Segreviewers field


thanks,


love
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12082553
Dim session As New NotesSession
     Dim user As Variant
     
     Dim ws As New notesuiworkspace
     Dim Source2 As notesuidocument
     Dim curdoc As notesdocument
     Set Source2=ws.currentdocument
     Set curdoc=Source2.document
     
     Dim tmpnum As String
     Dim tmpname As String
     
     tmpuser = session.CommonUserName



vValues = curdoc.GetItemValue ( "segreviewer" ) 'is a multivalue
'and then replace the values with:
Call curdoc.ReplaceItemValue( "segreviewer" , Fulltrim ( Arrayreplace ( vValues , tmpuser , "" ) ) )

if the above doen't work let me know.

0
 
LVL 19

Expert Comment

by:madheeswar
ID: 12082595
this worked fine for me:
Sub Click(Source As Button)
      Dim session As New NotesSession
      Dim user As Variant
      
      Dim ws As New notesuiworkspace
      Dim Source2 As notesuidocument
      Dim curdoc As notesdocument
      Set Source2=ws.currentdocument
      Set curdoc=Source2.document
      
      Dim tmpnum As String
      Dim tmpname As String
      
      tmpuser = session.CommonUserName
      
      
      
      vValues = curdoc.GetItemValue ( "test" ) 'is a multivalue
'and then replace the values with:
      
      Call curdoc.ReplaceItemValue( "test" , Fulltrim ( Arrayreplace ( vValues , tmpuser , "" ) ) )
End Sub
0
 
LVL 14

Expert Comment

by:p_partha
ID: 12087325
Love
You can use a simple @formula to do this:

@trim(@Replace(SegReviewers;@username;""));


If you still want it in lotusscript itself, then you can use evaluate, it will be faster and efficient:

somethign like this:

Dim session As New NotesSession
      Dim user As Variant
      
      Dim ws As New notesuiworkspace
      Dim Source2 As notesuidocument
      Dim curdoc As notesdocument
      Set Source2=ws.currentdocument
      Set curdoc=Source2.document
      
      Dim tmpnum As String
      Dim tmpname As String

      k =    Evaluate(|@Trim(@Replace(SegReviewers;@name([cn];@username);""))|,curdoc)
      
      
      Call source2.Save     Call source2.Refresh

0
 

Author Comment

by:lovemeto
ID: 12100161
mad thanks a lot this solution will help me a lot.. thanks..
thanks to other guys that give their answer.
0
 
LVL 19

Accepted Solution

by:
madheeswar earned 1000 total points
ID: 12109361
Lovemeto,
Then please accept the answer and Grade with "A".

Thanks
maddy
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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.

Join & Write a Comment

Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Watch the software video of Kernel Import PST to Office 365 tools which can easily import PST and OST files to Office 365 for bulk mailboxes. The process of migration is simple and user can map source and destination mailboxes and easily import data…

595 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