Home > Domino Tips > Developer > Other > Change a field value from a view on the Web
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

OTHER

Change a field value from a view on the Web


trevor wright
05.12.2003
Rating: -3.20- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


We needed to be able to update a document from a view, without opening the document. I used a $$ViewTemplate and in the view column added an html field to allow the value to be changed and when changed call a JavaScript function to run an agent to change the field value and reload the form.



Code

in the view column:
temp := @DocNumber("");
"<tr><td><input type=text  
id=chField"+ temp+ " onChange=chTAS
("" +@Text(@DocumentUniqueID) + """ +  
"," +  """ +temp   +  "") value=""+
PPriorityRO +""></td>"

in the JSHeader:
function chTAS(uid ,pval){
var f = document.forms[0];
var refer = f.HTTP_Referer.value;
if(refer ==""){
refer = "http://" + f.Cluster_Name.value 
+ "/" + f.DBName.value; 
}
var ch = "f.chField" + pval + ".value";
var npval =  eval(ch);
OpenAgent&UNID=" + uid + "&PVal=" + ch;
var strurl = refer + "/sTASPri?
OpenAgent&UNID=" + uid + "&PVal=" + npval;
this.location = strurl;
}
Agent to save document & refresh the view:
Dim db As NotesDatabase
Dim agent As NotesAgent
Dim server As String
Dim view As NotesView
Dim webDoc, doc As notesDocument
Dim urlstr As String
Dim agentLog  As NotesLog
Dim dbname As String
Dim ename As String
Dim tmpvar As Variant
Dim evalstr As Variant
Dim DocID As String
Dim querystring As String
Dim unid As String
Dim wunid As String
Dim prival As String
Dim UID As String
Dim wView As notesview
Dim wDb As notesdatabase
Dim wDoc As notesdocument
Dim wKey As String
Dim newname As String
Dim referer As String
Dim priority As String


Sub Initialize
 On Error Goto errHandler
 Dim session As New notessession 
 Set agentLog = New notesLog
("Save TASPriorities Log Info")
 Call agentLog.OpenAgentLog 
 Set db=session.currentdatabase
 Set webDoc = session.DocumentContext
 
 referer = webdoc.HTTP_Referer(0)
 Set view = db.GetView("TASPRO")
 evalstr = "@ReplaceSubString
(@SubSet(@DBName;-1);"""";""/"")"
 tmpvar = Evaluate(evalstr)
 dbname = Cstr(tmpvar(0))
 querystring=webDoc.Query_String(0)
 
 priority = webdoc.PPriority(0)

 If(Instr(querystring,"&UNID=") >0)Then
  wunid$ = parsequerystringforentry
(querystring,"&UNID=")
  prival$ = parsequerystringforentry
(querystring,"&PVal=")
  Dim newfld As Variant
  Call setdoc(wunid$,prival$)
  Call agentLog.Close
  Exit Sub
 Else
  wunid$ = webdoc.UIDCheck(0)   
 End If

 eName = parsequerystringforentry
(querystring,"&Name=")

 If(eName <> "")Then  
  Call replace20(eName,newname)
 End If

 If(wunid$ <> "") Then
  Set doc = db.getdocumentbyUNID
(wunid$) 
 Else 
  Goto newDoc
 End If
 
 If Not doc Is Nothing Then
  unid$ = doc.UniversalID
  doc.PPriorityRO=webdoc.PPriority(0)
  doc.PNameRO=newname
  doc.PSearchIDRO = webdoc.PSearchID(0)
  doc.PWIDRO = webdoc.PWID(0)
  doc.PAppIDRO = webdoc.PAppID(0)
  doc.PEstHoursRO =  webdoc.PEstHours(0)
  doc.PDueDateRO = webdoc.PDueDate(0)
  doc.PPCompRO = webdoc.PPComp(0)
  doc.PHrsRemRO = webdoc.PHrsRem(0)
  doc.PTAllocRO = webdoc.PTAlloc(0)
  doc.PStatusRO = webdoc.PStatus(0)
  Call doc.save(True,True)
 Else 
newDoc:
  Set doc = db.CreateDocument
  doc.form = "TASPRO"
  doc.PPriorityRO=webdoc.PPriority(0)
  doc.PNameRO=newname
  doc.PSearchIDRO = webdoc.PSearchID(0)
  doc.PWIDRO = webdoc.PWID(0)
  doc.PAppIDRO = webdoc.PAppID(0)
  doc.PEstHoursRO = webdoc.PEstHours(0)
  doc.PDueDateRO = webdoc.PDueDate(0)
  doc.PPCompRO = webdoc.PPComp(0)
  doc.PHrsRemRO = webdoc.PHrsRem(0)
  doc.PTAllocRO = webdoc.PTAlloc(0)
  doc.PStatusRO = webdoc.PStatus(0)
  Call doc.save(True,True)
 End If 
 
 urlstr = "/" + dbname+ "/$$TASPRO?
OpenForm&Name=" & newName
 
 Print "[" +  urlstr + "]"
 Call agentLog.Close
 
 Exit Sub 
errHandler:
 Print "<a>Error in Save (sTASPri) 
Line# " + Format$(Erl()) + ": " + Error$ +"
 (" + Cstr(Err) + ")<a>"
End Sub

Sub setdoc(sunid As String,prval As String)
 Set doc = db.getdocumentbyunid(sunid)
 If Not doc Is Nothing Then
  doc.PPriorityRO = prval
  newname = doc.PNameRO(0)
  Call doc.save(True,True)
  urlstr = "/" + dbname+ "/$$TASPRO?
OpenForm&Name=" & newName
 End If
End Sub
  
 

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Other
Create a dynamic user-driven navigator for a Notes/Domino application
How to apply XSL style sheets to XML views
Comparing replicas on clustered Lotus Domino servers
Creating a Lotus Notes view column categorized by month
Using the XMLHTTP object for integration with Domino or any RDBMS back end
Hiding field properties/data from DocProperties box
Export a view to Excel without coding
Prevent document deletion if there are response documents
Switching between test IDs quickly
AddParameter to a NotesXSLTransFormer

JavaScript for Lotus Notes Domino
Trap JavaScript runtime errors in Domino Web apps
JavaScript workaround fixes Lotus Notes 8.x PostOpen event issue
Write HTML and JavaScript in Notes view rows and columns on the Web
JavaScript detects Web browser type and version in Notes/Domino 8.0.2
JavaScript creates a jump box on a Lotus Notes Web form
Top 10 Lotus Notes/Domino coding and development tips of 2008
How to create dynamic JavaScript in Notes Domino without formulas
Trap an attachment path via the Domino file upload control field
Converting Lotus Notes views to XML documents using JavaScript
Mimic Lotus Notes Domino application functionality on the Web

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts