diff --git a/file.js b/file.js index 750b08d..85deb4c 100644 --- a/file.js +++ b/file.js @@ -20,7 +20,7 @@ const authConfig = { async function initializeSalesforceConnection() { // sfdc.setProductionBaseUrl(); // or sfdc.setSandboxBaseUrl(); - sfdc.setSandboxBaseUrl(); // Example: using sandbox + sfdc.setProductionBaseUrl(); // Example: using sandbox sfdc.setTokenFile(authConfig.sfdcTokenFile); sfdc.setClientId(authConfig.sfdcClientId); sfdc.setClientSecret(authConfig.sfdcClientSecret); @@ -91,7 +91,7 @@ async function attachPdfToAccount(sfdc, tempFiles, isDryRun = false) { // if codice fiscale is not available, I search the user's account based on their name and lastname const soql = `SELECT Id, Name FROM Account WHERE (${conditions.join(' OR ')}) ORDER BY CreatedDate DESC LIMIT 1`; const result_soql = await sfdc.query(soql); - + if (result_soql && result_soql.records && result_soql.records.length > 0) { // if we find something let matchFound = result_soql.records[0]; console.log('--- Match found! ---'); @@ -105,8 +105,8 @@ async function attachPdfToAccount(sfdc, tempFiles, isDryRun = false) { PathOnClient: `${ result_soql.records[0].Name }_Document.pdf`, VersionData: base64Pdf, // Must be Base64 string FirstPublishLocationId: `${ result_soql.records[0].Id }`// Automatically creates the link to the Account! - }); - + }); + //const accountName = result_soql.records[0].Name; const nowIsoString = new Date().toISOString(); // current timestamp in UTC const todayDate = new Date().toISOString().split('T')[0]; @@ -117,7 +117,10 @@ async function attachPdfToAccount(sfdc, tempFiles, isDryRun = false) { Data_Caricamento__c: nowIsoString, Tipo_Documento__c: "Dossier di Tirocinio", Stato__c: 'Valido' - }) + }); + + console.log(`Name: ${ result_soql.records[0].Name }`); + console.log(`Id: ${ result_soql.records[0].Id }`); } } else {