You need to sign in to do that
Don't have an account?
Edward Foreaker 2
Could Anyone Assist Me With Unit Testing This? Thanks.
public with sharing class ehsSignatureExtensionController {
private final My_Work_Order__c ehs;
public ehsSignatureExtensionController(ApexPages.StandardController controller) {
ehs = (My_Work_Order__c)controller.getRecord();
}
@RemoteAction public static RemoteSaveResult saveSignature(Id ehsId, String signatureBody) {
Attachment a = new Attachment(ParentId=ehsId, name='Signature.png', ContentType='image/png', Body=EncodingUtil.base64Decode(signatureBody));
Database.saveResult result = Database.insert(a,false);
RemoteSaveResult newResult = new RemoteSaveResult();
newResult.success = result.isSuccess();
newResult.attachmentId = a.Id;
newResult.errorMessage = result.isSuccess()?'':result.getErrors()[0].getMessage();
return newResult;
}
public class RemoteSaveResult {
public Boolean success;
public Id attachmentId;
public String errorMessage;
}
public pageReference saveSignature(){
pageReference page = new PageReference('https://cunning-fox-3wdgx9-dev-ed.lightning.force.com/lightning/r/My_Work_Order__c/'+ehs.id +'/view');
page.setRedirect(true);
return page;
}
}
private final My_Work_Order__c ehs;
public ehsSignatureExtensionController(ApexPages.StandardController controller) {
ehs = (My_Work_Order__c)controller.getRecord();
}
@RemoteAction public static RemoteSaveResult saveSignature(Id ehsId, String signatureBody) {
Attachment a = new Attachment(ParentId=ehsId, name='Signature.png', ContentType='image/png', Body=EncodingUtil.base64Decode(signatureBody));
Database.saveResult result = Database.insert(a,false);
RemoteSaveResult newResult = new RemoteSaveResult();
newResult.success = result.isSuccess();
newResult.attachmentId = a.Id;
newResult.errorMessage = result.isSuccess()?'':result.getErrors()[0].getMessage();
return newResult;
}
public class RemoteSaveResult {
public Boolean success;
public Id attachmentId;
public String errorMessage;
}
public pageReference saveSignature(){
pageReference page = new PageReference('https://cunning-fox-3wdgx9-dev-ed.lightning.force.com/lightning/r/My_Work_Order__c/'+ehs.id +'/view');
page.setRedirect(true);
return page;
}
}
Are you looking for test class ? if yes please refer the below one.
Thanks,
Maharajan.C
All Answers
Are you looking for test class ? if yes please refer the below one.
Thanks,
Maharajan.C
I just wanted to say thank you very much for the unit test, it validated and deployed all thanks to you. I marked your answer as the best. I really appreciate your help. The saveSignature method is working for desktop only. I am trying to get the saveSignature() redirect to work on the mobile lightning app also. Could you see below and advise if the visualforce script/apex method can be adjusted to redirect to the lightning mobile object(tablet/mobile form factor) as it properly does on desktop? I will Post a second question called "How To: Save button method for Desktop and Mobile.Thanks.", this way I can mark your answer as best for a second question if you know the answer. Nonetheless, thank you my friend.
ehsSignatureExtensionController Extension - Desktop Page Ref Part of the Apex
Visualforce Page saveSignature() Script