?
Solved

Help with replace number script

Posted on 2004-08-23
14
Medium Priority
?
241 Views
Last Modified: 2013-12-18
HI Guys

Having a bit of problem with the following

I have 2 views

PRUNID which returns a pr_Link1 field value which is the UNID of a parent doc
PRCPR view categorized on PRUNID which is the UNID of the document

On the PR doc there is a field name PRNumber
I need to find the matching PR UNID numbers and replace them wilth PRNumber

Here is what I have so far
Dim s As New notesSession
      Dim db As notesDatabase
      Set db = s.currentDatabase
      Dim poview As notesView
      Dim prview As notesView
      Dim dc As NotesDocumentCollection
      Set poview = db.getView("PRUNID")
      Set prview = db.getView("PRCPR")
      Dim podoc As notesDocument
      Dim prdoc As notesDocument
      Set prdoc = prview.getFirstDOcument
      'Set podoc = poview.getFirstDOcument
      
      PRUNID= prdoc.PRUNID(0)
      'POUNID =podoc.pr_link1(0)
      PRNumber = prdoc.PRNumber(0)
      
      
      Do Until prdoc Is Nothing
            
            Set dc = poview.GetAllDocumentsByKey("PRUNID", True)
      '      If PRUNID = POUNID Then
            Call dc.StampAll("pr_link1", PRNumber)
      '      End If
            Set prdoc = prview.getNextDocument(prdoc)
            'call podoc.Save( False, False )
      Loop
0
Comment
Question by:imjamesw
  • 7
  • 5
  • 2
14 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11873009
This line is the problem...Set dc = poview.GetAllDocumentsByKey("PRUNID", True)

It should be

Set dc = poview.GetAllDocumentsByKey(PRUNID, True)


~Hemanth
0
 

Author Comment

by:imjamesw
ID: 11873382
PR_Link1 is not an actual field

It is created virtually when a PO is created

Is this a problem?

I have tried creating a field and doing a refresh but I am getting killed by an other validation on the form

Any way around that?
0
 

Author Comment

by:imjamesw
ID: 11873413
Also currently ther is no save

Does Call dc.StampAll("pr_link1", PRNumber)
Also save the doc
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 15

Expert Comment

by:Bozzie4
ID: 11873628
Stampall also saves the document.

And what do you mean 'PR_LINK1 is not an actual field?'  It's not on the form ?  That's no problem, it should be in the document properties when you select the document in a view.

cheers,

Tom
0
 

Author Comment

by:imjamesw
ID: 11873669
Yes I can see it in the properties
0
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 800 total points
ID: 11873765
It doesn't matter..

After changing the line I mentioned.. did that help ?

Your loop and variables seems to have been misplaced and doesn't align correctly

You said that pr_link1 is the link for prdoc.. use that to lookup the prdoc and then extract the value of prnumber and stamp it..

so your loop should be like this

set podoc = poview.GetFirstDocument

while not podoc is nothing
 Set prdoc = prview.GetDocumentByKey( podoc.pr_link1(0), true)
 podoc.prnumber = prdoc.prnumber
 podoc.save true,false
 Set podoc = poview.GetNextDocument(podoc)
wend
0
 

Author Comment

by:imjamesw
ID: 11873808
This is not working
I thik the problem is I have nothing to compare against

I want to get the UNID  from the PRCPR view then use that to lookup the UNID's that are the same in the PRUNID view then next doc in the PRCPR view until nothing

Dim s As New notesSession
      Dim db As notesDatabase
      Set db = s.currentDatabase
      Dim poview As notesView
      Dim prview As notesView
      Dim dc As NotesDocumentCollection
      Set poview = db.getView("PRUNID")
      Set prview = db.getView("PRCPR")
      Dim podoc As notesDocument
      Dim prdoc As notesDocument
      Set prdoc = prview.getFirstDOcument
      
      
      PRUNID= prdoc.PRUNID(0)
      PRNumber = prdoc.PRNumber(0)
      
      
      Do Until prdoc Is Nothing
                        Set dc = poview.GetAllDocumentsByKey(PRUNID, True)
            
                  Call dc.StampAll("pr_link1", PRNumber)
                  Set prdoc = prview.getNextDocument(prdoc)
            
      Loop
0
 
LVL 15

Accepted Solution

by:
Bozzie4 earned 1200 total points
ID: 11873870
I don't understand the logic.  What's the use in looping the PRDOC's when you stamp everything with the same number (the 1 from the first document) ?

Dim s As New notesSession
     Dim db As notesDatabase
     Set db = s.currentDatabase
     Dim poview As notesView
     Dim prview As notesView
     Dim dc As NotesDocumentCollection
     Set poview = db.getView("PRUNID")
     Set prview = db.getView("PRCPR")
     Dim podoc As notesDocument
     Dim prdoc As notesDocument
     Set prdoc = prview.getFirstDOcument
     
     
     Do Until prdoc Is Nothing
PRUNID= prdoc.PRUNID(0)
     PRNumber = prdoc.PRNumber(0)
                    Set dc = poview.GetAllDocumentsByKey(PRUNID, True)

if dc is nothing then
print "No matches for " & PRUNID          
elseif dc.count < 1 then
print "No matches for " & PRUNID      
else
               Call dc.StampAll("pr_link1", PRNumber)
end if
               Set prdoc = prview.getNextDocument(prdoc)
         
     Loop
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11873972
imjamesw, you are confusing...

What you have to do is extract value from prdoc and plug it inside the podoc...RIGHT ?

Coming to your own logic..

PRUNID and PRNUMBER are extracted from the view first doc and plug it into all podoc.. That is what your script is doing..

Instead you have to look into podoc and get link to prdoc and then extract the value and plug it inside the podoc.. that is what I provided above ! So what is that you are confusing with ??
0
 

Author Comment

by:imjamesw
ID: 11873977
That is the whole point

I have a PR it may have several PO's associated with it or a t leat one

THe current system used UNIDs to associate documents
That worked fine until the documents were archived and the UNID changed

I  created a new number field on the PR; form and Im going to use the PRNumber to replace the UNIDs that are associated with it
0
 

Author Comment

by:imjamesw
ID: 11874231
Bozzie

I tried yours and it worked on one document the rest were unchanged. I could see the unid in the debugger and the PRnumber change however it did not change on the PO dox .except for the first one
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11881615
So this is a one time fix ?

If so then use pr_link1 to do a dblookup to prunid view and extract prnumber and plug it. Use toolsrefreshselecteddocs command to run on this docs to re-evaluate the pr_link1 field value.. Any problem in doing this ? I believe this is the easiest way.
0
 

Author Comment

by:imjamesw
ID: 11881644
HI Hemanth

I finally got it to run

The problem was I had made a copy of the original database and the unid had changed, so I madae a replica and ran the agent and all worked as i hoped it would

Thanx for you patience

0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 11881692
cool.. so much of sweat uh !
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

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.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
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 anti-spam), the admin…
Suggested Courses
Course of the Month17 days, 2 hours left to enroll

864 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