Registering New Document Programmatically in Salesforce
Monday, September 18, 2023 at 04:40pmWe are implementing new functionality related to Proctors (document type) and we need to create a new declaration. In the process, created new Document_Proctor like Declaration_FYLSX, however we are facing issues with new document. This is in UAT.
Do we need to register Blob# or Name at your end as it says Bad Request? Please advise.
Below are the errors:
New document: Declaration_Proctor
10:10:23:593 USER_DEBUG [244]|DEBUG|StaticResource:{Id=0813R000000CdhXQAS, Body=Blob[14151]}
10:10:23:173 USER_DEBUG [231]|DEBUG|=> Response from createPackageExample: F8sF_hpz_100v5a7tQd6FBe63rs=
Line: 738, Column: 1
OneSpanRESTAPIHelper.OneSpanRestAPIHelperException: Error creating OneSpan package with documents:
400 - Bad Request - {"code":400,"technical":"Unexpected Content-Disposition value for parameter 'name'",
"messageKey":"error.validation.invalidParameters","message":"Invalid parameters.","name":"Validation Error"}
Existing Declaratiom_FYLSX:
10:13:49:470 USER_DEBUG [231]|DEBUG|=> Response from createPackageExample: 1T18amg-U1iZPvav1Qznlf5tGfQ=
10:13:50:029 USER_DEBUG [244]|DEBUG|StaticResource:{Id=081t00000008XLAAA2, Body=Blob[34561]}
No Error
Reply to: Registering New Document Programmatically in Salesforce
Tuesday, September 19, 2023 at 10:23amHi Sam,
From the error message "Unexpected Content-Disposition value for parameter 'name'"", it sounds like the raw request format might have some problem.
What's the document type (PDF, Word, etc.) associated to this custom object? What if you associated with another file? Which SDK function the code uses to upload the document?
Duo
Reply to: Registering New Document Programmatically in Salesforce
Tuesday, September 19, 2023 at 04:15pmYes, the name is causing the issue, we have introduced new document with name Declaration_Proctor. The new document has been defined in a similar fashion as earlier ones and new name is not associated with any other file. Below is the method we are invoking for document creation.
Could you please check if there are any restrictions or naming conventions to follow to get successful response.
Reply to: Registering New Document Programmatically in Salesforce
Tuesday, September 19, 2023 at 04:43pmHi Sam,
I see, these Word files are stored as StaticResource in Salesforce. I've seen the same error in a few recent cases(case1, case2, case3). Although I can't reproduce the same in my test environment, but there are two proposed solution:
(1)Try to convert the Word file to PDF and reupload the static resource.
(2)There's another way to create package and add document in a single API call, which should resolve this error:
OneSpanSDK sdk = new OneSpanSDK();
//Create package
OneSpanAPIObjects.Package_x pkg = new OneSpanAPIObjects.Package_x();
pkg.name = 'Example Transaction - ' + Datetime.now().format();
pkg.status = OneSpanAPIObjects.PackageStatus.SENT;
//Create Roles
String roleId1 = 'Signer1';
OneSpanAPIObjects.Role role1 = new OneSpanAPIObjects.Role();
role1.signers = sdk.createRolesSigner('John', 'Smith', '[email protected]', 'CEO', 'ABC Bank');
role1.id = roleId1;
role1.name = roleId1;
pkg.roles = new List<OneSpanAPIObjects.Role>{role1}; //add role
//Prepare Documents Blob
String document1Name = 'Document1';
StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'testdoc1' LIMIT 1];
Map<String,Blob> documentBlobMap = new Map<String,Blob>();
documentBlobMap.put(document1Name, sr.Body);
//Create Document Metadata
OneSpanAPIObjects.Document document1 = new OneSpanAPIObjects.Document();
document1.name = document1Name;
document1.id = document1Name;
OneSpanAPIObjects.Field field = new OneSpanAPIObjects.Field();
field.left = 208;
field.width = 200;
field.height = 50;
field.top = 518;
field.page = 0;
field.subtype = 'CAPTURE';
field.type = 'SIGNATURE';
List<OneSpanAPIObjects.Field> fields = new List<OneSpanAPIObjects.Field>();
fields.add(field);
OneSpanAPIObjects.Approval approval = new OneSpanAPIObjects.Approval();
approval.fields = fields;
approval.role = roleId1;
List<OneSpanAPIObjects.Approval> approvals = new List<OneSpanAPIObjects.Approval>();
approvals.add(approval);
document1.approvals = approvals;
pkg.documents = new List<OneSpanAPIObjects.Document>{document1}; //add document
//Send package One Step
String packageId = sdk.createPackage(pkg,documentBlobMap);
System.debug('PackageId: ' + packageId);
Duo
Reply to: Registering New Document Programmatically in Salesforce
Friday, September 22, 2023 at 11:37pmHi Duo ;
They had some success but now they are getting the error I uploaded as an image - Trusted Type Policy creation blocked by Content Security policy
Reply to: Registering New Document Programmatically in Salesforce
Monday, September 25, 2023 at 08:30amHi Sam,
Unfortunately, I am not aware of this pendor.js script. Could you elaborate the nature of the issue a little bit, like what's the behavior you are experiencing and what steps to reproduce the issue?
Duo
Reply to: Registering New Document Programmatically in Salesforce
Tuesday, September 26, 2023 at 01:30pmIssue: After loading one span URL data on the LWC component(Iframe) and click on the page, we are getting below highlighted error from pendo.js file (see previous file we uploaded which is a javascript file from OneSpan package.
Is it possible to schedule a call you?
Reply to: Registering New Document Programmatically in Salesforce
Tuesday, September 26, 2023 at 01:34pmHi Sam,
I saw this error message in developer console even if I directly launched the signing URL in a new tab, see attachment. Let me check if this is a known issue or you can go ahead and create a support ticket reporting this. (However I doubt this error will affect the normal signing flow)
Duo
Reply to: Registering New Document Programmatically in Salesforce
Thursday, September 28, 2023 at 12:27pmHi Duo;
They would like to schedule a call with you but I am guessing you want to check on whether this is a known issue first. Pleased advise.
Thanks!!
Reply to: Registering New Document Programmatically in Salesforce
Thursday, September 28, 2023 at 12:32pmHi Sam,
Yes, I've checked the previous tickets and this is a known issue. Please fill in a support ticket and have the issue reported.
Duo