Solved

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

Posted on 2004-09-16
12
195 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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