Wednesday 12 August 2009

Ajax dblookup to get value in combo

**Ajax dblookup code "Get the value in second combo based on the choise of first combo"**
This is easy to get values in other field based on the selection of text in one field without refreshing the whole form. This is all we can do with Ajax code.
This code i have tested in Mozilla and IE and working like charm!
How to Use:-
1) Form in which you want to use this ajax dblookup code
take a field named
"path" type text put default value @WebDbName
2) Take two field combo type say named "fieldselect" and "fieldget"
3) In "fieldselect" enter formula for your choices or enter choices (Whatever value you want in first field) to get the value
// Above was the designing and accessing value in fields with formula and all that your Ajax code will start now//
4) On change of "fieldselect" put follwing code:-

Tdatabase =document.forms[0].path.value; // Accessing Database NameObjT1=document.forms[0].fieldselect; //Making object of first field
keyVal=ObjT1.options[ObjT1.selectedIndex].text;
ObjT2=document.forms[0].fieldget; //Making object of second field
dbLookup("",Tdatabase,"Test",keyVal,2) //dbLookup (server,database,view,key,column)
5) In JS Header of the form Put following Code(Just Copy and Past):-
var TReq;
var ObjT2;
/*////////--Dblookup function ---////////*/

function dbLookup(server,database,view,key,column)
{
server = window.location.hostname;
if( !isNaN(column) )
column -= 1;
viewurl = "http://"+trim(server)+"/"+trim(database)+"/"+view+"?Readviewentries&restricttocategory="+key
if (window.XMLHttpRequest) //for Mozilla
{
TReq = new XMLHttpRequest();
}
else if (window.ActiveXObject) // for IE
{
TReq = new ActiveXObject("Microsoft.XMLHTTP");
}
TReq.onreadystatechange = responseState;
TReq.open("GET", viewurl, true);
TReq.send(null);
}
function responseState()
{
if (TReq.readyState == 4) // Continue when Response from sever has arrived
{
if (TReq.status == 200) // Continue when everything is ok
{
response = TReq.responseXML;Mylookup(response)
}
else
{
alert("You are not getting the data check it" + TReq.statusText);
}
}
}
/* //// Extract Lookup value form XML data ////*/

function Mylookup(responseXML)
{
NodeList = responseXML.getElementsByTagName("viewentry")
var strValue="";
var Tsep="";
for(var i=0; i
{
strValue =strValue+Tsep+NodeList[i].getElementsByTagName("text")[0].childNodes[0].nodeValue
Tsep="¿"
}
strValuesplit = strValue.split("¿")
generateCombo(strValuesplit,ObjT2)
}
/*//////// Trim Function*/

function trim(str)
{
return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
/*//Getting value in cobmo Function//*/

function generateCombo(data,inField)
{
inField.length=0
inField.length +=1
inField[inField.length-1].text = "--Select--"
for(vCount=0;vCount
{
inField.length +=1strText=data[vCount]
if (strText !=undefined && strText != null)
{
inField[inField.length-1].text = trim(strText)
}
}
}

Find the full Running code in images.
Because due to the some html code above part missing some line code.
1stimage:

2ndimage:

Tuesday 11 August 2009

Deatch File After new mail has arrived

Hi this agent will deatch file when new mail will arrived.
Some points to this agent:
1) This will override the file if same file name will exist.
2) If there are two mail having the same file name will only export the last mail file.
(If you want to export all attachment, attachment name should be different)
3) In agent prooerties in second tab chek Allow for restricted Operation.
4) This agent will deatch file in servers C drive's Deatch Folder
5) If you will manually trigger this agent then it will deatch file on the same system C drive's deatch folder as path given
Deatch Agent Code:
Declaration:-
Dim session As NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument


Initialize:-
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
Set collection = db.UnprocessedDocuments
For i = 1 To collection.Count
Set doc = collection.GetNthDocument( i )
If doc.HasEmbedded Then
Call detach( doc )
End If
Next
End Sub

Deatch Function:-
Sub detach( doc As NotesDocument )
Dim rtitem As Variant
Set rtitem = doc.GetFirstItem( "Body" )
Forall items In rtitem.EmbeddedObjects
If items.Type = EMBED_ATTACHMENT Then
Call items.ExtractFile( "C:\Detach\" & items.Source )
End If
End Forall
End Sub

Monday 10 August 2009

Search text having bracket in lotus

Now you can search text having bracket
Like you want to search Tej Dixit(Hi)What you should do
1) Put " double quotesbefore opening of the first bracket.
2) Put " double quotes after closing of the first bracket.
3) This is not matter how many brackets are in a search text you ca search for nested bracket
also.
Things should be clear
ex: let you want to search Tej [Dixit(welcome)]
Then seacrh text with " will be
Tej "[Dixit(welcome)]"
In your code replace the same, you will get the result