Solved

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

Posted on 2004-09-16
12
188 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
Comment Utility
it can be done through ArrayReplace
0
 
LVL 19

Expert Comment

by:madheeswar
Comment Utility
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
Comment Utility
thanks for quick response!
what do you mean by fetdoc is from another view?


you mean i need to create a view?

thanks
0
 
LVL 19

Expert Comment

by:madheeswar
Comment Utility
no need . that is for ur understanding
0
 
LVL 13

Expert Comment

by:CRAK
Comment Utility
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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:lovemeto
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Lovemeto,
Then please accept the answer and Grade with "A".

Thanks
maddy
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

  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…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now