Skip to main content

#Automation36 utenti parlano di questo argomento

Alessandro Di Stefano ha fatto una domanda in #Data360

Hi everyone,

I am designing a Data Cloud flow where a CRM staging object is regularly purged due to retention rules. In Data Cloud, we need to keep the processed data in a permanent target table for audit purposes, even after the source records are deleted.

With UI-based Batch Data Transforms, platform-managed Full Refreshes periodically rebuild the target table from scratch based only on current source data. This would wipe out our historical target records once the source is purged.

I want to confirm how Python Custom Code Extensions (PySpark SDK) handle this:

  1. When using client.write_to_dmo(..., write_mode=WriteMode.APPEND), does PySpark strictly append new rows without ever wiping or truncating the target table?
  2. Is PySpark execution completely immune to automatic platform Full Refreshes, meaning Data Cloud will never automatically wipe and rebuild a target table written via Custom Code?
  3. Under WriteMode.MERGE, if a record is deleted from the source table, can we confirm it remains untouched in the target table rather than being deleted?

Has anyone implemented this pattern for keeping permanent history from short-lived staging sources in Data Cloud?

Thanks!  

 

#Data360  #Automation

2 risposte
  1. 21 set, 20:46

    Hi Alessandro,

    Regarding your design pattern for preserving historical audit records from short-lived staging sources in Data Cloud, here are the technical confirmations for how PySpark Custom Code Extensions handle write operations: 

     

    1.WriteMode.APPEND Execution:Append Behavior. 

    When using client.write_to_dmo(..., write_mode=WriteMode.APPEND), PySpark strictly appends new incoming rows to the target Data Model Object (DMO) or Data Lake Object (DLO) without truncating or wiping existing data. It will never automatically rebuild or clear out historical rows. 

     

    2.Immunity to Full Refreshes:Platform Independence. 

    PySpark code execution is completely separate from the platform-managed Full Refresh schedules used by standard UI Batch Data Transforms. Data Cloud will not automatically trigger a full rebuild or drop table operation on targets populated via Custom Code Extensions. 

     

    3.WriteMode.MERGE and Source Deletions:Merge Behavior on Deletions. 

    Under WriteMode.MERGE, records that are deleted or purged from the source staging table remain untouched and preserved in the target table. Merge updates or inserts matching records based on keys, but it does not propagate source deletions to remove historical records from the target.

0/9000
Suraj Demgunde ha fatto una domanda in #Sales Cloud

How can we cover attached method. can some help me in this.

 

test method cover

 

#Sales Cloud  #Marketing Cloud  #Analytics  #Nonprofit  #Trailhead  #Automation  #New Releases  #Integration  #AppExchange

1 risposta
  1. 21 set, 20:47

    Hi Suraj,

    To write a unit test for a @future (callout=true) method, you need to mock the HTTP callout (using HttpCalloutMock) and enclose the execution between Test.startTest() and Test.stopTest(). Salesforce runs all asynchronous methods (like future methods) called within startTest() and stopTest() synchronously right when Test.stopTest() executes. 

     

    Here is an example test class structure to cover your method:

    1.Create a Mock Callout Class:

    Mock Implementation. 

    Create a mock class that implements HttpCalloutMock to return a fake JSON response simulating your patchCall output (ensuring it contains 'state' => 'Success' and a valid JSON structure with an id field).

    2.Prepare Test Data and Context:

    Test Setup. 

    In your test method, insert a test Bid_Review_Request__c record so that the update brUpdate; statement can successfully find and update a record in the database.

    3.Wrap in Start/Stop Test:

    Execution and Assertion. 

    Assign your mock, wrap the future method call inside Test.startTest() and Test.stopTest(), and assert that the record was updated successfully.

    Apex 

     

    @isTest

    private class NewProjectHandlerTopUpTest {

    // 1. Mock class for HTTP callouts

    public class MockHttpResponseGenerator implements HttpCalloutMock {

    public HTTPResponse respond(HTTPRequest req) {

    HttpResponse res = new HttpResponse();

    res.setHeader('Content-Type', 'application/json');

    res.setStatusCode(200);

    // Construct JSON response matching the parser requirements

    res.setBody('{"state": "Success", "resBody": "{\\"id\\": \\"12345\\"}"}');

    return res;

    }

    }

    @isTest

    static void testNewProjectHandlerTopUp() {

    // Create test record to satisfy update operation

    Bid_Review_Request__c testReq = new Bid_Review_Request__c(

    Name = 'Test Project'

    // Add required fields for Bid_Review_Request__c here

    );

    insert testReq;

    Map<String, String> recordMap = new Map<String, String>{

    'ID' => testReq.Id,

    'Name' => 'Test Project'

    };

    // Set mock callout

    Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());

    Test.startTest();

    // Calling the future method

    YourClassName.newProjectHandlerTopUp(recordMap, '{"test":"json"}', 'destination', 'WBS123');

    Test.stopTest(); // Future method executes here

    // Assertions to verify the record was updated

    Bid_Review_Request__c updatedReq = [SELECT WBS_Project__c FROM Bid_Review_Request__c WHERE Id = :testReq.Id];

    System.assertEquals('12345', updatedReq.WBS_Project__c, 'The WBS Project code should be updated successfully.');

    }

    }

    (Note: Replace YourClassName with the actual name of the Apex class containing your future method).

0/9000
James K.k ha fatto una domanda in #Salesforce Platform

I’m working with a Salesforce Flow that processes a relatively large number of records, and I’m looking for ways to improve its performance and reliability. 

 

The Flow currently performs several record queries and updates during execution. As the amount of data increases

,

the Flow takes longer to complete and can sometimes approach Salesforce governor limits. 

 

What are some recommended approaches for optimizing a Flow in this situation? For example, would reducing Get Records operations, using collections more effectively, or moving some logic to Apex help? 

 

I’d appreciate any practical suggestions or best practices for designing scalable Salesforce Flows. 

 

#Salesforce Platform  #*saleforce Platform Basic* - Understand The Salesforce Architecture  #Flows  #Slack Developers  #Automation

1 risposta
  1. 21 set, 20:46

    Hi James,

    Optimizing Salesforce Flows for large data volumes is crucial to avoid hitting governor limits (such as CPU time limits, SOQL query counts, and DML limits). Here are the recommended best practices and approaches to scale your flows: 

     

    1.Reduce Get Records Operations:Query Optimization. 

    Avoid placing Get Records or Update/Delete Records elements inside loops. Performing queries or DML operations inside loops quickly exhausts governor limits. Instead, fetch all required data in a single Get Records query

    before

    the loop, and store the results in a record collection. 

     

    2.Use Collections Effectively:Collection Processing. 

    Process data in-memory using collection variables and collection filters. Accumulate records that need to be created, updated, or deleted into a collection variable throughout the flow, and perform a single bulk Create, Update, or Delete operation outside of the loop. 

     

    3.Move Complex Logic to Apex:Logic Offloading. 

    If your flow involves complex iterative logic, heavy mathematical calculations, or complex data manipulations that exceed efficient flow capabilities, consider encapsulating that logic within an Invocable Apex action. Apex handles large data volumes and bulk processing much more efficiently and respects governor limits differently. 

     

    4.Evaluate Record-Triggered Flow Design:Execution Strategy. 

    Ensure your record-triggered flows use Fast Field Updates (Before-save) whenever you only need to update fields on the triggering record itself, as these execute significantly faster without triggering additional system overhead. For asynchronous processing, consider utilizing scheduled paths or asynchronous execution when immediate execution isn't strictly required.

0/9000

Hi all,

 

I've created a flow so that whenever the opportunity owner field is updated, the related contact owner field is also updated to be the same.

 

I thought it'd be quite simple, which it was, but during testing it keeps throwing the error in the title which says the ownerID field is blank, but it's not. Not on the Opportunity and not on the Contact.

 

I've googled endlessly and can't find a solution, any help is greatly appreciated!

Flow error - INVALID_CROSS_REFERENCE_KEY: Owner ID: owner cannot be blank.

2 risposte
  1. 21 set, 06:34

    Hi Charlie,

     

    This error (INVALID_CROSS_REFERENCE_KEY: Owner ID: owner cannot be blank) typically occurs for one of two main reasons when attempting to update Contact ownership from an Opportunity:

     

    1. How is the Flow referencing the Contact? (Primary Suspect)

    By default, standard Opportunities do not have a direct lookup to ContactId unless you are using:

     

    • Custom fields (e.g., a custom Primary_Contact__c lookup).

     

    • Opportunity Contact Roles (OpportunityContactRole).

     

    Check your Update Records element:

     

    • If your flow is trying to update records of type Contact using a filter like Id Equals $Record.ContactId (or an empty custom lookup field), that lookup value is resolving to null/blank.

     

    • When Salesforce receives an update request for a Contact where the target record ID or lookup resolution fails/is null, it often misinterprets the payload and throws Owner ID: owner cannot be blank or an INVALID_CROSS_REFERENCE_KEY.

     

    • Fix: Verify how your Opportunity finds the related Contact. If you use Opportunity Contact Roles:

     

      1. Add a Get Records element to find the OpportunityContactRole where OpportunityId Equals $Record.Id (and optionally IsPrimary Equals True).
      2. Add a Decision element to check if a Contact Role was found ({!Get_Contact_Role} Is Null False).
      3. In your Update Records element, update the Contact where Id Equals {!Get_Contact_Role.ContactId}, setting OwnerId = $Record.OwnerId.

     

    2. Is the New Opportunity Owner an Active User?

    • Unlike Accounts, Leads, and Cases, Contacts cannot be owned by Queues—a Contact's OwnerId must always resolve to an active User ID (prefix 005).

     

    • If your Flow is passing a Queue ID, or if the user being assigned is inactive or lacks the necessary license/permissions on the Contact object, Salesforce rejects the assignment with this cross-reference error.

     

    • Ensure you are mapping:
      • Field: OwnerId
      • Value: {!$Record.OwnerId} (make sure you select the ID itself, not a related field like Owner:User > ContactId).

     

    3. Contact "Private Record" Sharing Restriction

    In Salesforce's standard data model, a Contact without an AccountId is considered a private contact and has strict ownership rules:

     

    • If the related Contact is not associated with an Account, changing its owner requires specific permissions and cannot always inherit owners dynamically.

     

    • Ensure the target Contact has an associated AccountId.

     

    Quick Debugging Tip:

    Run your flow using the Debug button in Flow Builder with the specific Opportunity record ID where you saw the failure. Look at the right-hand debug panel under the Update Records step—it will show the exact values being passed into OwnerId and Id.

     

    Hope this helps track down the culprit!

0/9000

I need to create a formula field that updates a checkbox after verifying Company's value. I couldn't complete creating a formula field as it throws an error that the limit is 5000 characters. I want to query many company values and update the checkbox. Can someone please suggest an alternative to achieve this functionality?

 

Can I create a trigger or apex class? 

 

#Sales Cloud #Analytics #Automation #Integration Would creating that be affected by character limits as well?

1 risposta
  1. 17 set, 14:07

    Hi SidParnam,

    If you're maintaining a long list of company names in a formula, I wouldn't recommend moving the same large IF/OR logic into Apex. Apex doesn't have the formula field's 5,000-character limit, but hard-coding a large company list makes the solution difficult to maintain.

    A better approach would be to store the company values as configuration:

    • Create a Custom Metadata Type with the company name and the checkbox value.
    • Use a before-save Record-Triggered Flow to look up the company and set the checkbox.
    • If you need more complex processing or a very large dataset, Apex can also query the configuration and update the record.

    This way, adding or removing a company doesn't require changing and redeploying your formula/Apex code. 

     

    If you share approximately how many company values you have and whether the checkbox needs to update immediately when the Company field changes, we can suggest the simplest implementation. 

0/9000

This is regarding a forced updated effective Jan 2022. 

I found an article related to it https://help.salesforce.com/articleView?id=sf.icu_migration_how.htm&type=5

 

I just want to get a picture on the steps you took and things you checked and how you did it to adopt to these new changes.  Thank you in advance!

 

#ICU Locale Formats  #Service Cloud  #Automation  #New Releases

1 risposta
  1. 17 set, 14:07

    Hi Robert,

    For the ICU Locale Format migration, I would recommend treating it as a testing/impact-assessment exercise rather than just changing the setting.

    A few things to check:

    • Review the Salesforce ICU Locale Format Migration documentation and identify which locales your org uses.
    • Test date, time, number, currency, and address formatting for your supported locales.
    • Pay particular attention to Apex, Visualforce, LWC/Aura, integrations, reports, and any custom JavaScript that parses or formats dates/numbers.
    • Test automation such as Flows, validation rules, formulas, and email templates where locale-dependent values are involved.
    • Test integrations carefully if they exchange formatted dates/numbers with external systems.
    • Enable ICU in a sandbox first, run regression testing, and compare the results with the existing format.
    • Document any impacted customizations and update them before enabling it in production.

    The main risk is usually custom code or integrations that assume a specific date/number format rather than Salesforce's locale-aware formatting.

    If you share which Salesforce products/customizations you're using, I can suggest a more specific migration checklist. 

0/9000

#Trailhead  #Automation #TrailblazerCommunity #Trailblazers #Analytics

There is a request from an internal team at the organization to send a report extract from Salesforce to a shared network drive within the organization for a bot to pickup. Is there a way to automate this within Salesforce? 

1 risposta
  1. 17 set, 14:05

    Hi Rashi,

    Salesforce doesn't natively write files directly to an organization's shared network drive. A common approach is to use an external integration or middleware between Salesforce and the network location.

    For example:

    1. Schedule a Salesforce report/export or query the required records through the Salesforce API.
    2. Have an integration service retrieve the data on a schedule.
    3. The integration writes the generated CSV/file to the shared network drive for the bot to process.

    Depending on your environment, this could be implemented using MuleSoft, an ETL/integration platform, or a small scheduled service that uses the Salesforce API. 

     

    If the requirement is specifically for a scheduled Salesforce report export, rather than querying the data directly, the available options are different. Sharing the required file format, frequency, and whether middleware is already available would help determine the best approach. 

0/9000

Would changing the passwords

 

#Automation #New Releases #AppExchange length on password policies affect the existing users password assigned?

1 risposta
  1. 17 set, 14:04

    Hi Branden, 

     

    Changing the minimum password length in Salesforce Password Policies does not immediately change or invalidate passwords that existing users have already set. 

     

    The new policy applies when users set or change their passwords going forward. Existing passwords can remain as they are until the user changes/resets the password. 

     

    If you want to force existing users to comply with the new password policy, you would need to have them reset their passwords (or use an appropriate administrative process). 

0/9000
Michael Dely ha fatto una domanda in #Service Cloud

I would like to change a rating from 5-star to 3-star.  I created a picklist titled, "Grade," and the values are 1,2,3.  Then I have a formula field with the following, 

 

IMAGE( CASE(Grade__c, "1", "/img/samples/stars_100.gif", "2", "/img/samples/stars_200.gif", "3", "/img/samples/stars_300.gif", "/img/samples/stars_000.gif"), "WAS Rating")

 

Even though I only selected 1,2,3 for my picklist and 1,2,3 in the formula, the field still shows 5 available stars.  I want this to show 3 available stars.  Please let me know how I can do this.  

 

Thanks, 

Mike

 

#Service Cloud  #Marketing Cloud  #Analytics  #Trailhead  #Automation

1 risposta
  1. 17 set, 14:03

    Hi Michael,

    The issue is that /img/samples/stars_100.gif, stars_200.gif, and stars_300.gif are Salesforce's sample images, and those images are based on the standard 5-star rating scale. Changing the picklist values doesn't change the number of stars in the image itself. 

     

    If you want a true 3-star display, you'll need to use your own 3-star image files as a Static Resource and reference those in the formula.

    For example:

    IMAGE(

    CASE(

    Grade__c,

    "1", "/resource/YourStarResource/star_1.png",

    "2", "/resource/YourStarResource/star_2.png",

    "3", "/resource/YourStarResource/star_3.png",

    "/resource/YourStarResource/star_0.png"

    ),

    "Rating"

    )

    Create the appropriate 0-, 1-, 2-, and 3-star images and upload them as a Static Resource. That way the displayed scale is actually limited to 3 stars. 

0/9000

I see from this idea exchange item that you can send an email alert when I

 

#Sales Cloud #Service Cloud #Trailhead #Automation #New Releases new note is created a record, but the link is broken. Does anyone know how to accomplish sending email alerts when someone adds a new note? 

 

https://ideas.salesforce.com/s/idea/a0B8W00000GddhfUAB/emailchatter-notifications-on-notes-and-attachments-updates

1 risposta
  1. 17 set, 14:02

    Hi Bob,

    If you're referring to Enhanced Notes, you can automate this using the ContentNote and ContentDocumentLink objects. 

     

    One approach is to use a record-triggered Flow on ContentDocumentLink to detect when a note is linked to the record, then send an email notification to the appropriate users. 

     

    Keep in mind that ContentDocumentLink is used for linking the Note to records, so you'll need to determine the linked record and recipients before sending the notification. 

     

    If you share which record you want to notify users about (Account, Contact, Opportunity, etc.) and whether you're using Enhanced Notes, I can suggest the exact Flow configuration. 

0/9000