Standard New and Edit functionality


public with sharing class ReadingPermissionController {

public ReadingPermission__c newReadingPermission {get;set;}
public String returnUrl {get;set;}

public ReadingPermissionController(ApexPages.StandardController setCon) {
ReadingPermission__c r = (ReadingPermission__c) setCon.getRecord();
newReadingPermission = new ReadingPermission__c();
if(r.Id != null) {
newReadingPermission = [Select Id, Name, Permission_Holder_Name__c, Permission_Holder_ID__c, Permission_Holder_Type__c, Granted_Permissions__c from ReadingPermission__c where id =: r.Id];
}
//system.assert(false, newReadingPermission );
returnUrl = apexpages.currentPage().getParameters().get('retURL');
}

public List getReviewerList() {
List options = new List();
options.add(new SelectOption('' , '--None--'));
List users = [Select Id, name from user where profileId in: OnlineReadingBaseClass.getOnlineReadingProfileIds()];
for(User u : users) {
options.add(new SelectOption(u.Id, u.Name));
}
return options;
}

public List getQueueList() {
List sOptions = new List();
List groupList = [select Id, name from Group where type = 'Queue'];
sOptions.add(new SelectOption('' , '--None--'));
for(Group g : groupList) {
sOptions.add(new SelectOption(g.Id , g.Name));
}
return sOptions;
}

public List getGroupList() {
List sOptions = new List();
List groupList = [select Id, name from Group where type = 'Regular'];
sOptions.add(new SelectOption('' , '--None--'));
for(Group g : groupList) {
sOptions.add(new SelectOption(g.Id , g.Name));
}
return sOptions;
}

public PageReference save() {
PageReference pag = null;
try {
upsert newReadingPermission;
pag = new PageReference(returnUrl);
} catch(Exception e) {
ApexPages.addMessages(e);
}
return pag;
}

public PageReference saveAndNew() {
PageReference pag = null;
try {
upsert newReadingPermission;
newReadingPermission = new ReadingPermission__c();
} catch(Exception e) {
ApexPages.addMessages(e);
}
return pag;
}

public PageReference cancel() {
return new PageReference(returnUrl);
}
}




#loading-image {
position: fixed;
top: 40%;
left: 40%;
}

#loading {
width: 100%;
height: 100%;
top: 0px;
left: 0px;
position: absolute;
display: none;
opacity: 0.5;
filter: alpha(opacity = 50);
-moz-opacity: 0.5;
background-color: #fff;
text-align: center;
z-index: 100;
}



//function for showing loading image
function showLoadingImage() {
document.getElementById('loading').style.display='block';
}


//function for hiding loading image
function hideLoadingImage() {
document.getElementById('loading').style.display='none';
}


Loading...


































Published by Sandeep Kumar

He is a Salesforce Certified Application Architect having 11+ years of experience in Salesforce.

Leave a Reply