Created
November 6, 2013 16:53
-
-
Save quintonwall/7339715 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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