Skip to content

Instantly share code, notes, and snippets.

@msrivastav13
Last active December 18, 2015 17:18
Show Gist options
  • Save msrivastav13/5817171 to your computer and use it in GitHub Desktop.
Save msrivastav13/5817171 to your computer and use it in GitHub Desktop.
global with sharing class AngularJSDemoCtrl {
public class Accountwrap {
Accountwrap() {
Website = '';
AccountSource = '';
Phone = '';
Type = '';
}
public string id;
public string name;
public string Website;
public string AccountSource;
public string Phone;
public string Type;
}
global static String getlstAccount() {
List < Accountwrap > lstwrap = new List < Accountwrap > ();
List < account > lstacc = [SELECT Id, Name, Phone, Type, Website, AccountSource
FROM Account
];
for (Account a: lstacc) {
Accountwrap awrap = new Accountwrap();
awrap.id = a.id;
awrap.name = a.name;
if (a.Website != null) {
awrap.Website = a.Website;
}
if (a.Phone != null) {
awrap.Phone = a.Phone;
}
if (a.Type != null) {
awrap.Type = a.Type;
}
if (a.AccountSource != null) {
awrap.AccountSource = a.AccountSource;
}
lstwrap.add(awrap);
}
return JSON.serialize(lstwrap);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment