Solved

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

Posted on 2004-09-16
12
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 250 total points
ID: 12109361
Lovemeto,
Then please accept the answer and Grade with "A".

Thanks
maddy
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

710 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