Solved

Help with replace number script

Posted on 2004-08-23
14
221 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
 
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
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…

743 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

13 Experts available now in Live!

Get 1:1 Help Now