How can I retrieve the record ID in the context of IWC?

32    Asked by debbieJha in Salesforce , Asked on Apr 16, 2024

I am currently working on a project in which I am using IWC for workflow management. In a particular workflow step, I need to fetch the unique record ID of a particular item that was just processed. How can I retrieve this particular record ID within the context of IWC? 

Answered by Colin Payne

In the context of Salesforce, You can retrieve the record ID in IWC by using the “recordId” variable. This will hold the unique identifier of the record that is currently being processed in the workflow.

Here is the example given of how you can use the “recordId” variable in the context of IWC workflow:-

// Assume you have a function to fetch record details from a database or API
Function fetchRecordDetails(recordId) {
    // Your code to fetch record details using the recordId
    // This could be an AJAX request, database query, etc.
    // For demonstration purposes, let’s simulate fetching data
    Return {
        Id: recordId,
        Name: “Example Record”,
        Description: “This is a sample record fetched using the recordId”
    };
}
// Assuming you have an IWC workflow step where you want to get the recordId
// You can use the following code within that step
Function processRecord() {
    // Get the recordId from the built-in variable
    Var recordId = iwc.variables.recordId;
    // Fetch record details using the recordId
    Var recordDetails = fetchRecordDetails(recordId);
    // Log the fetched record details
    Console.log(“Record ID:”, recordDetails.id);
    Console.log(“Record Name:”, recordDetails.name);
    Console.log(“Record Description:”, recordDetails.description);
    // Now you can continue with your workflow processing using the fetched record details
}

Your Answer

Interviews

Parent Categories