When autocompleting Change Event fields from managed package SOBject it prefixes fields with package namespace.

Issue #2414 resolved
Justin Julicher created an issue

For Change Events it seems SF doesn’t prefix the fields with the namespace but IC will as it just copies the package objects fields?

Comments (14)

  1. Scott Wells repo owner

    Justin, I’m confused as to the issue. I have an org with a namespace and just wrote a simple Apex script to interact with one of the namespaced ChangeEvent objects with and without the namespace qualification on both the object and the fields, and it’s all resolving properly:

    Executing:
    ========================================================================================================
    base_dev__BasePackageObject__ChangeEvent changeEventNs = new base_dev__BasePackageObject__ChangeEvent();
    System.debug(changeEventNs.base_dev__ObjectId__c);
    
    BasePackageObject__ChangeEvent changeEventNoNs = new BasePackageObject__ChangeEvent();
    System.debug(changeEventNoNs.ObjectId__c);
    
    ========================================================================================================
    Success.
    

    Am I misunderstanding the issue?

  2. Justin Julicher reporter

    Hi Scott,

    I'll provide somw screenshots of what I'm experiencing when I get into work.

    This was actually from a managed package so I'm not sure if that will make a difference.

  3. Scott Wells repo owner

    Sounds good. I’ll be interested to see what’s actually happening as I would expect anything from a package with a namespace to require namespace qualification unless the local org (and corresponding IC2 project) shares that namespace.

  4. Justin Julicher reporter

    Ahh let me qualify it more....

    Its a managed oackage where i have added a field in the org to tthe package object.

    So the kocal field is coming through with a prefix when it shouldn't. Did that make sense?

  5. Scott Wells repo owner

    Ah, okay. So an org-local field that’s been added to a namespaced custom object from an installed managed package is being rendered into the OST with the installed packages’s namespace, correct?

  6. Scott Wells repo owner

    Okay. Should be easy enough to reproduce. I’ll play with a bit tomorrow and let you know how/where it goes. Thanks for the clarification!

  7. Scott Wells repo owner

    Hmmmm…I’m not seeing that behavior. Here’s the OST representation for a namespaced packaged custom object with a local custom field:

    // Generated by Illuminated Cloud on Tue Aug 22 10:04:37 CDT 2023. Do not edit.
    
    global class /*al__*/Foo__ChangeEvent extends SObject 
    {
        /**
         * <h3><b>Checkbox</b></h3>
         * <h3><b>Field Attributes</b></h3>
         * <table border="0" valign="top">
         * <tr><td nowrap><b>Data Type:</b></td><td nowrap>Checkbox</td></tr>
         * <tr><td nowrap><b>External ID:</b></td><td nowrap>false</td></tr>
         * <tr><td nowrap><b>Default Value:</b></td><td><pre>false</pre></td></tr>
         * </table>
         */
        global Boolean al__Checkbox__c;
        /**
         * <h3><b>Currency</b></h3>
         * <h3><b>Field Attributes</b></h3>
         * <table border="0" valign="top">
         * <tr><td nowrap><b>Data Type:</b></td><td nowrap>Currency(16,2)</td></tr>
         * <tr><td nowrap><b>Required:</b></td><td nowrap>false</td></tr>
         * <tr><td nowrap><b>External ID:</b></td><td nowrap>false</td></tr>
         * </table>
         */
        global Decimal al__Currency__c;
    
        ...
    
        /**
         * <h3><b>Local Custom Field</b></h3>
         * <h3><b>Field Attributes</b></h3>
         * <table border="0" valign="top">
         * <tr><td nowrap><b>Data Type:</b></td><td nowrap>Text(10)</td></tr>
         * <tr><td nowrap><b>Required:</b></td><td nowrap>false</td></tr>
         * <tr><td nowrap><b>Unique:</b></td><td nowrap>false</td></tr>
         * <tr><td nowrap><b>External ID:</b></td><td nowrap>false</td></tr>
         * </table>
         */
        global String LocalCustomField__c;
    
        ...
    
        global Foo__ChangeEvent()
        {
        }
    }
    

    One thing that may be different, though…do you have the local custom field in your local project metadata? If not, can you please retrieve it into the project, regenerate the OST, and see if that resolves the issue?

  8. Justin Julicher reporter

    Hi Scott,

    The package is Mission Control.

    line 1 is reporting incorrect compile and is what auto-completed and won’t save. Line 2 is the issue resolved and will save.

    I have CompletionDate__c in my local metadata and have recently re-generated the OST.

    Here a link to the video: https://services.testim.io/storage/test-projects-artifacts/1UMDiL03AdnEGaYQV8qX/video-file_eC0hLcq9xc8Uua6q.webm?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlpHNVdKaVBhbEtpNko2eTJBMXZ0IiwiaWF0IjoxNjkyNzQ1NzQ2LCJleHAiOjE2OTI3NDkzNDZ9.d8SV6gT5Acm1p6NNJna5oAmKHjUYdOzdRidvvtSsXGw

    This is the entry in the OST for Milestone__ChangeEvent - looks like it is saved correctly there:

    // Generated by Illuminated Cloud on Tue Aug 22 17:16:33 AEST 2023. Do not edit.
    
    global class /*amc__*/Milestone__ChangeEvent extends SObject 
    {
    
        ... removed for brevity
    
        global Decimal amc__Total_Projected_Hours_Remaining__c;
        /**
         * <h3><b>Unallocated Milestone Budget</b></h3>
         * <h3><b>Field Attributes</b></h3>
         * <table border="0" valign="top">
         * <tr><td nowrap><b>Data Type:</b></td><td nowrap>Currency(16,2)</td></tr>
         * <tr><td nowrap><b>Formula:</b></td><td><pre>amc__Milestone_Budget__c -  amc__Hours_Scheduled_Cost__c</pre></td></tr>
         * <tr><td nowrap><b>Required:</b></td><td nowrap>false</td></tr>
         * <tr><td nowrap><b>External ID:</b></td><td nowrap>false</td></tr>
         * </table>
         */
        global Decimal amc__Unallocated_Milestone_Budget__c;
        global EventBus.ChangeEventHeader ChangeEventHeader;
        /**
         * <h3><b>Completion Date</b></h3>
         * <h3><b>Field Attributes</b></h3>
         * <table border="0" valign="top">
         * <tr><td nowrap><b>Data Type:</b></td><td nowrap>Date</td></tr>
         * <tr><td nowrap><b>Required:</b></td><td nowrap>false</td></tr>
         * <tr><td nowrap><b>External ID:</b></td><td nowrap>false</td></tr>
         * </table>
         */
        global Date CompletionDate__c;
        global User CreatedBy;
        global Id CreatedById;
        global Datetime CreatedDate;
    
        ... removed for brevity
    
        global Milestone__ChangeEvent()
        {
        }
    }
    

    Let me know if you need anything else.

  9. Scott Wells repo owner

    Ah, okay. I was able to reproduce it locally with that. Let me debug a bit and hopefully I’ll have a fix for this in tomorrow’s build. Thanks for providing all the diagnostic/repro info!

  10. Scott Wells repo owner

    Fixed. Short version is that the OST generates a file called META-INF/PackagedCustomObjectFields.properties that’s used to determine whether a field is packaged/namespaced or not for just this reason, and if you look at that file, you’ll see that it only includes the fields in their normal location and not on the ChangeEvent object. That’s why it works properly on Milestone__c but not Milestone__ChangeEvent. I’ve fixed that to canonicalize the variant objects to the real object for purposes of that check.

  11. Log in to comment