Hi, In “” table,the email address which is entered should not be a redundant one,the code which i have written does’nt work.can anybody help me telling what is the change do be done? public boolean validateWrite() { boolean ret; DirECommunicationAddress tDirECommunicationAddress; ret = super(); select firstonly tDirECommunicationAddress where tDirECommunicationAddress.ECommunicationTypeId == this.ECommunicationTypeId; if(this.ECommunicationTypeId) { { ret = checkfailed(“email Already exists”); } } return ret; }
Hi Rajarajeshwari,
It can be done by adding the Index in the table level and make **allow duplicated no…**then it will no allow the duplicates automatically…
Naresh Kolli
Hi Rajeswari,
check this link to use table method validateWrite()
http://axhelper.blogspot.com/2011/02/table-methods-task-17.html
ok,but if i need to do it through code ,how can i ?? coz i need to do the same for “vendor master address duplication” which i posted as my query today morning…can you please help/
HI Rajeswari,
if(this.ECommunicationTypeId != “”)
ret = super();
else
warning(" Please fill the Email value");
But sunil, i want to check whether the email entered by me does not match with the existing one (i.e. i should not have the same mail id twice)
Hi Rajarajeshwari,
public boolean validateWrite()
{
boolean ret;
DirECommunicationAddress tDirECommunicationAddress;
;
ret = super();
select firstonly tDirECommunicationAddress where tDirECommunicationAddress.ECommunicationTypeId == this.ECommunicationTypeId;
//The reason it is not working is because you are checking as this.ECommunicationTypeId instead of tDirECommunicationAddress.ECommunicationTypeId
if(tDirECommunicationAddress.ECommunicationTypeId)
{
ret = checkfailed(“email Already exists”);
}
return ret;
}
Check it know it will work…
Naresh Kolli
No Naresh, its not working. i’m not able to save a new record with different mail id .
Hi Rajeswari,
My code for make the field manditory.
As naresh said u can use Index or u can use the naresh code…
Hi,
Just remove the // ret = super(); line
public boolean validateWrite()
{
boolean ret;
DirECommunicationAddress tDirECommunicationAddress;
;
select firstonly tDirECommunicationAddress where tDirECommunicationAddress.ECommunicationTypeId == this.ECommunicationTypeId;
if(tDirECommunicationAddress.ECommunicationTypeId)
{
ret = checkfailed(" Email Already exists");
}
return ret;
}
no its not allowing to add a new rec. In the select query,no rec are considered…the value comes as " 0 "
Hi Rajarajeshwari,
Did you change in the if condition from this.ECommunicationTypeId to tDirECommunicationAddress.ECommunicationTypeId
Naresh Kolli
yes naresh,but still it does’nt allow me to add a new rec with diff mail id. and whn i debugg the ‘select’ query has value as ‘0’ for both the this.ECommunicationTypeId and tDirECommunicationAddress.ECommunicationTypeId
Check properly,
I tried its working, Send me ur code…
-i guess its a refreshing problem.
i’ve just copy pasted ur code…i’ve tried executing with “super()” and without “super()” ,but still it does not allow me to add a new rec with a different email id
no i’ve layered the table and again have written the code ,but getting the same problem
public boolean validateWrite() { boolean ret; DirECommunicationAddress tDirECommunicationAddress; str mail; ; ret = super(); select firstonly tDirECommunicationAddress where tDirECommunicationAddress.Email == this.Email; if(tDirECommunicationAddress.Email == this.Email) { ret = checkfailed(“email Already exists”); } return ret; }
Hi Rajarajeshwari,
Did you debug the code…When trying to insert the new record with the new email,it wont go into the if condition so it inserts the record…When trying to insert the existing email it finds the record and goes into the if condition and fails to insert the record…
Check by debugging it behaving like above or not…
Naresh Kolli