Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-16
12
Medium Priority
?
200 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
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 1000 total points
ID: 12109361
Lovemeto,
Then please accept the answer and Grade with "A".

Thanks
maddy
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

916 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