Home > Domino Tips > Developer > Domino > InViewEdit for the Web
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DOMINO

InViewEdit for the Web


Amar Deep Bhupathy
03.07.2005
Rating: -4.17- (out of 5)


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


InViewEdit functionality, introduced in R6, was a cool addition to Notes features. It was designed to enhance features available for Notes client. With most of the recent Domino applications being developed for the Web, it would be useful to mimic this functionality for Web applications.

By using a few age old techniques of Domino development, we can easily bring this concept into Web applications.

For example, lets take a small Web-based call management application that has a form for logging calls. It has a status field, which depicts the status of call. Now the helpdesk agent who accesses this application from the Web should be able to change the status from Web view.

  1. Create a view that will have HTML code put in their column formulas.

    Have the first column hold the UNID of the document.

     Col1 – 
     "<tr><td width='30'>
    <input type='hidden' name='Docunid_" 
    + @Text(@DocNumber) + "' value='" + 
     @Text(@DocumentUniqueID) + "'></td>"
    
     Col2 – Will display the name 
    of person to whom the call is assigned.
     "<td>"+  EnggName +"</td>"
    
     Col3 – Will hold the problem description
     "<td>"+problem + "</td>"
    
     Col4 – Will hold the HTML 
    for editable Status field
     Rem {
     StatusOptions – is a fieid in the 
    form which will hold the various 
    options available for status field
     Onchange event of status field we are
     calling a function which should 
     be declared in the view template we will use for this form
     };
    
     newList := @Transform(StatusOptions;"var";
     @If(var = Status ; "<option selected>" + var 
    + "</option>";"<option>" +  var+ "</option>"));
    
     "<td><select name='Status_"
    +@DocNumber+"' onchange='saveRecord
    (""+@DocNumber+"");' >" 
     + @Implode(newList) + "</select></td></tr>"
    

  2. Create a view template for the previous view (Form named $$ViewTemplate for YourviewName).

  3. Add server_name cgi hidden field and a hidden field (webDB) with formula as @WebDbName.
    
     Add a table tag
     <table width="450" border=1>
      <!-- $$ViewBody field here goes here 
     </table>
    
     Create Iframe 
     <iframe ID="agentOutput" height="50" 
    width="800" frameborder="0" 
    scrolling="no" src=""></iframe>
     
     In the JS header define the saveRecord function
     
     function saveRecord(docNumber) {
    
      var server = document.forms[0].Server_Name.value ;
      var dbpath = document.forms[0].webDB.value ;
      var docID = eval('document.forms[0].Docunid_' + 
    docNumber + '.value');
      var Status = eval('document.forms[0].Status_' + 
    docNumber +
       '.options[document.forms[0].Status_' + docNumber 
    +' .selectedIndex].text');
      var agentPath = "//" + server +"/" + dbpath + "/saveDoc?
    openagent&unid=" +
        docID + "& Status=" + Status;
    
      document.getElementById("agentOutput").src = 
    agentPath ;
     }
    
  4. Create an agent "saveDoc" to save the document specified by UNID in the agent URL.
     Sub Initialize
      On Error Goto errHandler
     
      Dim session As New notessession
      Dim db As NotesDatabase
      Dim contextDoc As NotesDocument
      Dim doc As NotesDocument
     
      Dim tmp As String
      Dim strUnID As Variant , strStatus As Variant
     
      Set db = session.CurrentDatabase
      Set contextDoc = session.DocumentContext
     
      tmp = contextDoc.Query_String_Decoded(0)
     
      strUnID = Evaluate
    (|@Right(@Word("|+tmp+|";"&";2);"=")|)
      strStatus = Evaluate
    (|@Right(@Word("|+tmp+|";"&";3);"=")|)
     
      Set doc = db.GetDocumentByUNID(strUnid(0))
     
      If Not doc Is Nothing Then
       doc.Status = strStatus
       Call doc.Save(False,False)
       Print "<b>" + doc.EnggName(0) + "'s call Saved 
    Successfully</b>"
      End If
      Exit Sub
     errHandler:
      Print "<b>Save failure: Error while saving the 
    document.</b>"
     End Sub
    

When the view is opened in the Web, Domino displays the view using the View Template we created. Now, when the user changes the status, saveRecord function is called, which calls the agent "Savedoc" and passes the UNID of the current doc and new status value as URL parameters. The agent gets these values and saves the changes in the corresponding document.

If you need to edit more than one field, then just append those values to the agent URL, access those values in the saveDoc agent and save those values in the backend document.

If you don't want the user to see the saveDoc agent output, reduce the width and height of Iframe to "0". Instead of using Iframe, you also make use of the popup window (create a new window and make its URL to agent URL).

Instead of using HTML in the view column, you can create a simple view and then create a form with a rich text field. In the Webqueryopen agent of that form, access the View, generate the required HTML and put this HTML string into the rich text field.

You will then need to add the JavaScript function to call the agent to save the changes in document and Iframe to display the agent output.

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Amar Deep Bhupathy. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

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
Domino
Mimic Lotus Notes Domino application functionality on the Web
A single form to view and edit any Lotus Notes document
DECS and DCR external data access considerations
How to create non-scrolling Lotus Domino view headers on the Web
Disabling the 'Submit' button on a form
An easier way to update a rich text field
Results from Default Notes Search have # of responses in brackets
Lotus Notes/Domino veteran offers comprehensive list of app dev tools
Notes to XML. . .and back again
Creating thumbnail images using LS2J in LotusScript

Web Development for Lotus Notes Domino
Trap JavaScript runtime errors in Domino Web apps
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
Top 10 Lotus Notes/Domino coding and development tips of 2008
Top 10 issues when developing Lotus Notes Domino Internet applications
Top 10 Lotus Notes Domino programming and development tips of 2007
Programmatically copy and hide attachments in Lotus Notes rich-text fields
Programmatically edit a rich-text field table from within the Lotus Notes client
Troubleshooting Lotus Notes Domino tabbed table problems
How to validate Lotus Notes forms on a Domino server without losing entered data

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