-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
27 lines (23 loc) · 1.18 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { InvocationEvent, Context, Logger, RecordQueryResult } from '@heroku/sf-fx-runtime-nodejs';
/**
* Describe Typescriptfunction here.
*
* The exported method is the entry point for your code when the function is invoked.
*
* Following parameters are pre-configured and provided to your function on execution:
* @param event: representative of the data associated with the occurrence of an event,
* and supporting metadata about the source of that occurrence.
* @param context: represents the connection to the the execution environment and the Customer 360 instance that
* the function is associated with.
* @param logger: represents the logging functionality to log given messages at various levels
*/
export default async function execute(
event: InvocationEvent<any>,
context: Context,
logger: Logger
): Promise<any> {
logger.info(`Invoking Typescriptfunction with payload ${JSON.stringify(event.data || {})}`);
const results = await context.org.dataApi.query('SELECT Id, Name FROM Account');
logger.info(JSON.stringify(results));
return `Hello Org ${context.org.id}, User ${context.org.user.username}. Your Org has ${results.records.length} Account records!`;
}