function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RiyajRiyaj 

How do i got return value from APEX Class???

Hello,

I m using APEX Class for Check my login form inputs..

Basically I m passing my Username, Password via function from aspnet page. In apex class following coding i m using... when after process this coding ( Username password is match retuen true, or false).. but I got a error when save this Apex Class...

How do I perform my login Username and Password is correct ? If Correct/wrong how do i return the value to asp.net page????

APEX Code
global class getLoginCheck{
 
  WebService static Lead getLoginCheckFromusername(string username,string password) {
 
   Contact r=[SELECT Count() from Contact WHERE Firstname = :username];
  Integer result = 0;
  if(r=0)
  {
  result = 0;
  }
    return result ;
    
  }
}

 



aspx.cs
getLoginInfo.Lead getLoginInfoFromUsername = getLoginInfoObj.getLoginCheckFromusername(txtUsername.text,txtPassword.text);
// Dropdown list name is ddlUsername

 



/**** How do I get return value from return fucnction from Apex Code and how to bind the all the retrn data's to dropdown list ****/
Best Answer chosen by Admin (Salesforce Developers) 
SFRajSFRaj

Try this

 

global class getLoginCheck{

WebService static boolean getLoginCheckFromusername(string username,string password) {

List<Contact> r=[SELECT Id from Contact WHERE Firstname = :username];

return r.size() < 0 ? false : true;

}
}

All Answers

kiranmutturukiranmutturu

try this

 

global class getLoginCheck{

WebService static boolean getLoginCheckFromusername(string username,string password) {

list<Contact> r=[SELECT Count() from Contact WHERE Firstname = :username];

return r.isEmpty ? false : true;

}
}

 

but i think this apex class needs to return a lead object to your .NET application...but as u are querying contact how can u get the lead?

RiyajRiyaj

When I m using your code...i

 

global class getLoginCheck{

WebService static boolean getLoginCheckFromusername(string username,string password) {

List<Contact> r=[SELECT Count() from Contact WHERE Firstname = :username];

return r.isEmpty ? false : true;

}
}

 

i got a error

 

 

Error: Compile Error: Illegal assignment from Integer to LIST<Contact> at line 5 column 1

SFRajSFRaj

Try this

 

global class getLoginCheck{

WebService static boolean getLoginCheckFromusername(string username,string password) {

List<Contact> r=[SELECT Id from Contact WHERE Firstname = :username];

return r.size() < 0 ? false : true;

}
}

This was selected as the best answer