diff --git a/file.js b/file.js index eb82a13..750b08d 100644 --- a/file.js +++ b/file.js @@ -91,16 +91,11 @@ 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); - //const soql2 = `SELECT Id, Name, ContentType, ParentId FROM Attachment WHERE ParentId='${ result_soql.records[0].Id }'`; - //const result2 = await sfdc.query(soql2); + 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! ---'); - /*console.log(`|-- Id: ${ matchFound.Id || 'N/D'} --- ${ result_soql.records[0].Id }`); - console.log(`|-- Name: ${ matchFound.Name || 'N/D'}`); - console.log(`|-- Account Salesforce: ${ result_soql.records[0].Name || 'N/D'}: ${ matchFound.Id }`); - console.log(`|-- ContentType: ${ matchFound.ContentType || 'N/D'}`);*/ - + if (isDryRun) { console.log('DRY RUN: non creato documento'); }