Solved

Help with replace number script

Posted on 2004-08-23
14
224 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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 200 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 300 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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