There is an inputText - string ( representing company name ): txt_NumeCompanie
Let's suppose there are already 2 docs. saved having the above field value: ABC
and Xpages
.
What I want to do:
- If I create a new doc. and I complete the company name field with
ABC
orXpages
, a message to appear letting me know a document exists already having that name. - If I open the document having
Xpages
as the company name and I'm changing it toABC
again the above message.
What I've tried: the onChange
event of the field refreshes a panel which contains a <xp:div styleClass="lotusMessage"
. This div has the following rendered property:
if ( currentDocument.isNewNote())
{
if ( @IsMember(Cdoc.getItemValueString("txt_NumeCompanie"),@Unique(@DbColumn(@DbName(),"vwComp",0))) )
{ return true;}
else { return false; }
}
else
{
var newe = Cdoc.getItemValueString("txt_NumeCompanie");
if ( @IsMember(newe,@Unique(@DbLookup(@DbName(),"vwCompanii",Cdoc.getDocument().getUniversalID(),2))) )
{ return false;}
else { return true; }
}
The vwCompanii
is having one column listing all the txt_NumeCompanie
values and vwCompanii
is having 2 columns: @Text(@DocumentUNiqueID))
and txt_NumeCompanie
'. The above code works fine for .isNewNote() documents.But, if I opened an existing doc. ( having txt_NumeCompanie = ABC ) the message appears again, without changing anything. I do want to cover also the 2. case from the above item list.
Also, by opening an existing doc. from the viewPanel, when the doc. is opened and displayed, the script message appears immediately even if the value of txt_NumeCompanie
hadn't been changed. How can I make the script message to be fired only when the onChange event is taking place, and not when the document is opened?
How can I achieve this?