NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Account accNew = new Account(Name='abcd');
insert accNew;

List<Contact> conNew = new List<Contact>();
conNew.add(new Contact(LastName='Whig'));
conNew.add(new Contact(LastName='Keneddy'));
conNew.add(new Contact(LastName='Singh'));
insert conNew;

for(List<Position__c> positions :[Select Status__c, Date_Closed__c from Position__c]){
for(Position__c pos: positions){
if( pos.Date_Closed__c < date.today()){
pos.Status__c = 'Closed';
}
}
update positions;
}

List<Position__c> updateList = [Select Status__c,Date_Closed__c from Position__c];

for(Position__c x:updateList){
if(x.Date_Closed__c > date.today()){
x.Status__c = 'Closed';
}
}
update updateList;

List<Position__c> updateSalary = [Select Status__c,Max_Pay__c from Position__c];
for(Position__c i:updateSalary){
if(i.Status__c == 'Open'){
i.Max_Pay__c = 80000;
}
}
update updateSalary;

List<Position__c> deleteList = [Select Status__c from Position__c];
for(Position__c i:deleteList){
if(i.Status__c == 'Closed'){
delete i;
}
}

Position__c newPos = new Position__c();
newPos.Name = 'Software Developer';
newPos.Status__c = 'Open';
newPos.Job_Description__c = 'This is Job Description';
insert newPos;

List<Position__c> newL = [Select Name, Max_Pay__c,Status__c from Position__c];
for(Position__c i:newL){
if(i.Name == 'Software developer'){
i.Max_Pay__c = 70000;
i.Status__c = 'Open';
}
}
update newL;

List<Position__c> newL = [Select Name, Max_Pay__c,Status__c from Position__c];
for(Position__c i:newL){
if(i.Name == 'DBA'){
i.Max_Pay__c = 50000;
i.Status__c = 'Open';
i.Job_Description__c = 'This is updated description';
}
}
update newL;

Position__c posNew = new Position__c(Name='HR Manager', Max_Pay__c=45000,Status__c='New', Job_Description__c='This is a job description');
insert posNew;


List<Position__c> posList = new List<Position__c>();
posList.add(new Position__c(Name='Manager',Status__c='New',Job_Description__c='Job_desc'));
posList.add(new Position__c(Name='Analyst',Status__c='New',Job_Description__c='Job_desc'));
posList.add(new Position__c(Name='CEO',Status__c='New',Job_Description__c='Job_desc'));
posList.add(new Position__c(Name='COO',Status__c='New',Job_Description__c='Job_desc'));
posList.add(new Position__c());

List<Database.SaveResult> srList = Database.insert(posList,false);

for(Database.SaveResult sr:srList){
if(sr.isSuccess()){
System.debug('Successfully Inserted' +sr.getId());
}
else{
for(Database.Error err:sr.getErrors()){
System.debug('The following error has occured');
System.debug(err.getStatusCode() + ':' + err.getMessage());
System.debug('Fields that affected this error' +err.getFields());
}
}
}

Account acc = new Account(Name = 'QWERTY');
Database.SaveResult sr = Database.insert(acc,false);

if(sr.isSuccess()){
String z = sr.getId();
List<Contact> conList = new List<Contact>();
conList.add(new Contact(LastName='N1',AccountId=z));
conList.add(new Contact(LastName='N2',AccountId=z));
conList.add(new Contact(LastName='N3',AccountId=z));
Database.insert(conList,false);
}
else{
for(Database.Error err : sr.getErrors()){
System.debug('The following error has occured');
System.debug(err.getStatusCode() + ':' + err.getMessage());
System.debug('Fields that affected this error' +err.getFields());

}}

//9.3

Lead Master = [Select LastName from Lead where LastName='x1'];
Lead NotMaster = [Select LastName from Lead where LastName='x2'];
Database.merge(Master,NotMaster, false);

//10.1

List<Lead> get = [Select Id,FirstName, LastName,Email from Lead];
System.debug(get);

//10.2

List<Account> acc = [Select Name from Account where BillingCity='New Delhi' OR BillingCity='Noida' ];
System.debug(acc);

//10.3
List<Contact> conlist = [Select Name from Contact];
System.debug(conlist);

//10.4
List<Opportunity> opps = [Select Name from Opportunity LIMIT 10];
System.debug(opps);

//10.5
List<Account> accs = [Select Name,AnnualRevenue from Account order by AnnualRevenue desc ];
System.debug(accs);

//10.6


//10.7
List<Lead> xy = [Select Count(Name),LeadSource from Lead group by LeadSource];
System.debug(xy);















     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.