Skip to content

Instantly share code, notes, and snippets.

@quintonwall
Created November 6, 2013 16:53
Show Gist options
  • Save quintonwall/7339715 to your computer and use it in GitHub Desktop.
Save quintonwall/7339715 to your computer and use it in GitHub Desktop.
public class RigController {
public RigController(ApexPages.StandardController controller) { }
@RemoteAction
public static String saveRig(String rigtype, String projectdetails, String discussion) {
String status = '';
Rig__c rig = new Rig__c();
rig.Rig_Type__c = rigtype;
rig.Project_Details__c = projectdetails;
rig.Discussion__c = discussion;
Database.SaveResult sr = Database.insert(rig, false);
if (sr.isSuccess()) {
System.debug('Successfully inserted rig. Rig ID: ' + sr.getId());
status = 'success';
}
else {
// Operation failed, so get all errors
for(Database.Error err : sr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Rig fields that affected this error: ' + err.getFields());
status = err.getStatusCode() + ': ' + err.getMessage();
}
}
return status;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment