Class to insert records into custom object?
public with sharing class studentinsert{
public Pagereference doInsert(){
student__c std=new student__c();
std.name=nameval;
std.email__c=emailval;
insert std;
pagereference ref =new pagereference('/apex/studentinserttest');
ref.setredirect(true);
return ref;
}
public String nameval{get;set;}
public String emailval{get;set;}
}
With Sharing:Enforces sharing rules that apply to current user.If absent,code is run under system context.
Pagereference:A reference to the visualforce page
Note:If we have parent and child classes; by default WITH SHARING is apply to two classes,so to avoid that salesforce introduce WITHOUT SHARING.
Without Sharing:Ensures that the sharing rules of the current user are not enforced.
public with sharing class studentinsert{
public Pagereference doInsert(){
student__c std=new student__c();
std.name=nameval;
std.email__c=emailval;
insert std;
pagereference ref =new pagereference('/apex/studentinserttest');
ref.setredirect(true);
return ref;
}
public String nameval{get;set;}
public String emailval{get;set;}
}
With Sharing:Enforces sharing rules that apply to current user.If absent,code is run under system context.
Pagereference:A reference to the visualforce page
Note:If we have parent and child classes; by default WITH SHARING is apply to two classes,so to avoid that salesforce introduce WITHOUT SHARING.
Without Sharing:Ensures that the sharing rules of the current user are not enforced.
Latest Certification Dumps of Salesforce , Amazon , IBM , Microsoft, SAP, Oracle , VMware available at https://www.ebsose.com or mail us at ebsosedotcom@gmail.com or certificationdirectdumps@gmail.com for any dumps / Superbadge /Development project queries . Get Fast replies and our team is available 24/7 . Success rate is 99.99% , so hurry and ping us .
ReplyDeleteReach out at ebsosedotcom@gmail.com for any development project or superbadge help required in salesforce or any other technology .