Agent does not pass values to a document ,was working in r5 but now it is not

Hello all:I have a huge problem

I have an agent that excutes from a hotspot button in the uidocument

the hot spot button code is:

Sub Click(Source As Button)

Dim boxType As Long, answer As Integer

If cdoc.gra_no(0) = “” Then

boxType& = MB_OK + 32

answer% = Msgbox(“The GRA No. is Obligatory,Please Enter a Value.” ,boxType&, _

	"Stop")

	Exit Sub

End If

If Check_Uniqueness_of_GRA=1 Then Exit Sub

Dim ws As New notesUIworkspace

Dim tmpDoc As NotesDocument

Dim agent As NotesAgent

Dim v As NotesView

Set agent = cdb.GetAgent("(Fill GRA Using LSXLC)")

Set tmpDoc=cdb.CreateDocument

Call cdoc.CopyAllItems(tmpDoc)

Call tmpDoc.save (True,True) 

Set v=cdb.getview("UNIDNEW")

Set uidoc=ws.currentdocument

Call uidoc.Save

If agent.RunOnServer( tmpDoc.NoteID ) = 0 Then

Msgbox(tmpDoc.NoteID)

Set tmpDoc=v.getdocumentByKey(tmpDoc.UNID(0))

If tmpDoc Is Nothing Then

Messagebox "An Error occured please contact your Notes Administrator",16, "Failure"

	Elseif tmpDoc.ErrText(0)<>"" Then

Messagebox tmpDoc.ErrText(0),16, “Failure”

Else

Set tmpuidoc=ws.EditDocument(True,tmpdoc)

Call uidoc.FieldSetText(“SaveOptions”,“0”)

Call uidoc.close

End If

	Set uidoc=ws.currentdocument

	Set cdoc=uidoc.document

	

If cdoc.gra_date(0) = "" Then

boxType& = MB_OK + 32

answer% = Msgbox(“This GRA No. does not Exist.” ,boxType&, _

“Stop”)

End If

Else

	Messagebox "Could not retrive data",16, "Failure"

End If

Call fill_click_field()

If Not(tmpDoc Is Nothing) Then tmpDoc.Remove(True) 

End Sub

so each time I run this code the agent is supposed to bring data from an as400 table and place it in the uidocument when debugging the agent the data is fine and all set but when debugging the document I find all values =“” nothing is transfered from agent to document

so if any one have any idea about this new 6 behaviour

here is the agent code just in case

thanx

‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’’

Sub Initialize

Dim NSession As New NotesSession

Dim db As notesDatabase

Dim agent As NotesAgent

Dim msghdr As String

Set agent = NSession.CurrentAgent

Set db = NSession.currentdatabase

Dim doc As NotesDocument

Dim sett_doc As NotesDocument

msghdr = "DB: GRA : Agent Fill GRA Using LSXLC): "

Msgbox msghdr + "Started"

Set doc = db.GetDocumentByID(agent.ParameterDocID)

Msgbox(agent.ParameterDocID)

Set sett_doc =db.GetProfileDocument("Workflow Settings")

If sett_doc Is Nothing Then

	doc.ErrText = "No Setting Document found"

	Call doc.save(True,True)

	Exit Sub

End If

Dim x As Currency

Dim i As Integer	

Dim src As LCConnection

Dim keyLst As New LCFieldList 

Dim field As LCField

Dim FieldOut As New LCFieldList

Dim count As Long

Dim KeyValue As String

Dim Session As New LCSession

Dim SQLString As String

session.ClearStatus

session.ClearStatus

Set src = New LCConnection ("db2") 

src.Database = sett_doc.data_source(0)

src.Userid = sett_doc.txt_user_name(0)

src.Password = sett_doc.txt_pass(0)



Call src.SetPropertyBoolean(4,True) 	src.Connect 		

KeyValue = doc.gra_no(0) 	

Set field = keyLst.Append("LLOT", LCTYPE_TEXT) 

field.Value = KeyValue 		

SQLString = "Select  LLOT,LPROD,LRDT,LMSC,LNMFGR,IUMS,IITYP,LRCPT,LNMLOT,LNCNTR,IDESC  from "+ sett_doc.txt_table(0) +_

" INNER JOIN "+sett_doc.DescTable(0)+" ON "+sett_doc.txt_table(0)+".LPROD = "+sett_doc.DescTable(0)+".IPROD"+_

" where LLOT = '"+ KeyValue +"' and (LMRB = 'H' or  LMRB = 'Q')   and (IITYP = 'R' or IITYP = 'P' or IITYP = 'B') "

Msgbox(1)

count =src.Execute(SQLString,FieldOut) 'Execute the Query

Dim strDate As String

count = src.Fetch(FieldOut)

If count<1 Then Exit Sub

If count> 0 Then

doc.gra_no=Cstr(FieldOut.LLot(0))	strDate=Mid(Cstr(FieldOut.LRDT(0)),7)+"/"+Mid(Cstr(FieldOut.LRDT(0)),5,2)+"/"+Left(Cstr(FieldOut.LRDT(0)),4)

	doc.gra_date = strDate		doc.pur_order_no=Cstr(FieldOut.LMSC(0))	doc.unit=Cstr(FieldOut.IUMS(0))		doc.ITYPE = Cstr(fieldout.IITYP(0))

doc.qty_rec=FieldOut.LRCPT(0)		doc.lot_no=Cstr(FieldOut.LNMLOT(0))	doc.item_desc=Cstr(FieldOut.IDESC(0))	Call doc.save(True,True)

Else

doc.ErrText=Cstr(KeyValue)+ " is not a Member"

End If



Call doc.save(True,True)

	src.DisConnect

End

	Call doc.save(True,True)

End Sub

Subject: agent does not pass values to a document ,was working in r5 but now it is not

I believe you are missing a delete, and still looking at a cached document. Compare your agent to the sample agent I published in the article about RunOnServer method, you will see an example.

Direct link in the article is in the Agent FAQ.