minor changes
This commit is contained in:
@@ -20,7 +20,7 @@ const authConfig = {
|
|||||||
|
|
||||||
async function initializeSalesforceConnection() {
|
async function initializeSalesforceConnection() {
|
||||||
// sfdc.setProductionBaseUrl(); // or sfdc.setSandboxBaseUrl();
|
// sfdc.setProductionBaseUrl(); // or sfdc.setSandboxBaseUrl();
|
||||||
sfdc.setSandboxBaseUrl(); // Example: using sandbox
|
sfdc.setProductionBaseUrl(); // Example: using sandbox
|
||||||
sfdc.setTokenFile(authConfig.sfdcTokenFile);
|
sfdc.setTokenFile(authConfig.sfdcTokenFile);
|
||||||
sfdc.setClientId(authConfig.sfdcClientId);
|
sfdc.setClientId(authConfig.sfdcClientId);
|
||||||
sfdc.setClientSecret(authConfig.sfdcClientSecret);
|
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
|
// 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 soql = `SELECT Id, Name FROM Account WHERE (${conditions.join(' OR ')}) ORDER BY CreatedDate DESC LIMIT 1`;
|
||||||
const result_soql = await sfdc.query(soql);
|
const result_soql = await sfdc.query(soql);
|
||||||
|
|
||||||
if (result_soql && result_soql.records && result_soql.records.length > 0) { // if we find something
|
if (result_soql && result_soql.records && result_soql.records.length > 0) { // if we find something
|
||||||
let matchFound = result_soql.records[0];
|
let matchFound = result_soql.records[0];
|
||||||
console.log('--- Match found! ---');
|
console.log('--- Match found! ---');
|
||||||
@@ -105,8 +105,8 @@ async function attachPdfToAccount(sfdc, tempFiles, isDryRun = false) {
|
|||||||
PathOnClient: `${ result_soql.records[0].Name }_Document.pdf`,
|
PathOnClient: `${ result_soql.records[0].Name }_Document.pdf`,
|
||||||
VersionData: base64Pdf, // Must be Base64 string
|
VersionData: base64Pdf, // Must be Base64 string
|
||||||
FirstPublishLocationId: `${ result_soql.records[0].Id }`// Automatically creates the link to the Account!
|
FirstPublishLocationId: `${ result_soql.records[0].Id }`// Automatically creates the link to the Account!
|
||||||
});
|
});
|
||||||
|
|
||||||
//const accountName = result_soql.records[0].Name;
|
//const accountName = result_soql.records[0].Name;
|
||||||
const nowIsoString = new Date().toISOString(); // current timestamp in UTC
|
const nowIsoString = new Date().toISOString(); // current timestamp in UTC
|
||||||
const todayDate = new Date().toISOString().split('T')[0];
|
const todayDate = new Date().toISOString().split('T')[0];
|
||||||
@@ -117,7 +117,10 @@ async function attachPdfToAccount(sfdc, tempFiles, isDryRun = false) {
|
|||||||
Data_Caricamento__c: nowIsoString,
|
Data_Caricamento__c: nowIsoString,
|
||||||
Tipo_Documento__c: "Dossier di Tirocinio",
|
Tipo_Documento__c: "Dossier di Tirocinio",
|
||||||
Stato__c: 'Valido'
|
Stato__c: 'Valido'
|
||||||
})
|
});
|
||||||
|
|
||||||
|
console.log(`Name: ${ result_soql.records[0].Name }`);
|
||||||
|
console.log(`Id: ${ result_soql.records[0].Id }`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user