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
jayakumarmjayakumarm 

Need code sample

i m new to salesforce.

 

using this to select

qr = binding.query("select Id,FirstName, LastName,Email,toLabel(Recordtype.Name) from Contact")

but i cnnt know

How to get the value in veriable what tolabel(Recordtype.Name) returns

 

 

TzafrirTzafrir

What do you mean by toLable? How can you insert that in a query string?

First do the query and after that parse the result.

HUGOBOSSHUGOBOSS
private void querySample() { //Verify that we are already authenticated, if not //call the login function to do so if (!loggedIn) { if (!login()) return; } QueryResult qr = null; binding.QueryOptionsValue = new apex.QueryOptions(); binding.QueryOptionsValue.batchSize = 3; binding.QueryOptionsValue.batchSizeSpecified = true; try { qr = binding.query( "select Id, Amount from Opportunity where Id = '006T00000044T7BIAU'"); if (qr.size > 0) { Opportunity account = ((Opportunity)qr.records[0]); Console.WriteLine("Found " + qr.size.ToString() + " accounts using Name = '006T00000044T7BIAU', ID = " + account.Id + " Amount = " + account.Amount); } else { Console.WriteLine("No records were found. Try running the create account sample."); Console.ReadLine(); } qr = binding.query("select FirstName, LastName from Contact"); bool bContinue = true; int loopCounter = 0; while (bContinue) { Console.WriteLine("\nResults Set " + Convert.ToString(loopCounter++) + " - "); //process the query results for (int i = 0; i < qr.records.Length; i++) { Contact con = (Contact)qr.records[i]; string fName = con.FirstName; string lName = con.LastName; if (fName == null) Console.WriteLine("Contact " + (i + 1) + ": " + lName); else Console.WriteLine("Contact " + (i + 1) + ": " + fName + " " + lName); } //handle the loop + 1 problem by checking to see if the most recent queryResult if (qr.done) bContinue = false; else qr = binding.queryMore(qr.queryLocator); } Console.WriteLine("\nQuery succesfully executed."); Console.Write("\nHit return to continue..."); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("\nFailed to execute query succesfully, error message was: \n" + ex.Message); Console.Write("\nHit return to continue..."); Console.ReadLine(); } }
HUGOBOSSHUGOBOSS

If that was unreadable, you want to build a while loop and loop through qr.records casting each qr.record[i] as a type of object you expect back.