[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Help with replace number script

Posted on 2004-08-23
14
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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