Salesforce Platform Event

Has anyone connected a Platform Event listener for Salesforce?

We are using the listener trigger but am getting this error:

System.SObjectException: Invalid field Id

Class.integrator_da.RealTimeExportIO.runInternal: line 50, column 1
Class.integrator_da.RealTimeExportIO.run: line 204, column 1
Class.integrator_da.RealTimeExporter.processExport: line 7, column 1
Class.CeligoRealTimeExportTriggerHandler.run: line 7, column 1
Class.rflib_TriggerManager.runHandlers: line 96, column 1
Class.rflib_TriggerManager.dispatch: line 78, column 1
Class.rflib_TriggerManager.dispatch: line 52, column 1
Trigger.ProvisionFulfillmentRequest: line 2, column 1

Also, how would we program the listener in Celigo for the Platform Event?

Best,

TJ

 

1

Comments

5 comments
Date Votes
  • Hi Limebox Consultant
        Will it be possible for you to share the "ProvisionFulfillmentRequest" trigger? there is something wrong with it, would like to look into it. 

    Thanks,

    0
  • Hello Muneswara,

    Thank you for replying. Here is the code from the client (they created it):

     

    public inherited sharing class CeligoRealTimeExportTriggerHandler implements rflib_TriggerHandler {
        rflib_Logger logger = rflib_LoggerUtil.getFactory()
            .createLogger(CeligoRealTimeExportTriggerHandler.class.getName());

        public void run(rflib_TriggerManager.Args args) {
            logger.info('Exporting records to Celigo');
            logger.info('Celigo Real Time Export Args: {0}', new List<Object>{ args });
            Provision_Fulfillment_Request__e capturedRecord = (Provision_Fulfillment_Request__e) args.newRecords.get(0);
           
            // get prefix for this sObjectType
            string prefix = args.objectType.getDescribe().getKeyPrefix();
            logger.info('Prefix: {0}', new List<Object>{ prefix });
           
            // does an Id exist already? (Oh, Salesforce doesn't like us doing this. Error.)
            logger.info('Real Id?: {0}', new List<Object>{ capturedRecord.Id });
           
            // Try setting with a test ID of all 0s, just to see what happens.
            capturedRecord.Id = prefix + '0'.repeat(12);
            logger.info('Mock Id: {0}', new List<Object>{ capturedRecord.Id });
           
            integrator_da.RealTimeExportResult res = integrator_da.RealTimeExporter.processExport();
            logger.info('Celigo Real Time Export Result: {0}', new List<Object>{ res });
        }

        public void onConsecutiveRun(rflib_TriggerManager.Args args, Integer numInvocation) {
            this.run(args);
        }
    }

     

    Please note, they tried adding the "Id" parameter as a "hack"... but it didn't work.

    0
  • Hi Limebox Consultant,

        This is the first time we see a Salesforce Platform event trigger, I did research on it. regarding your code "capturedRecord" will not have an id. actually, it's not a record it's a request input. I think even though we add a parameter for Id, most probably it may not work, because based on trigger context we will run soql query internally. platform event doesn't support soql query. it could one of the reasons for the exception for Id in the Salesforce package.

    Can you explain, how the process works in a client account?
    1) From where, Provision_Fulfillment_Request__e will be invoked?
    2) In Provision_Fulfillment_Request__e trigger what exactly the client is expecting to send the data to integrator.io. What exactly we are doing here?

    Another option that we can do is once we have the list sObject we can format it into payload (body) and in Apex class itself we can use HTTP request to send the data to IO webhook. this will solve the problem.

    But IMO, I think a better raise support ticket, will be useful from our end for better tracking purposes for these types of requests, we need more investigation on this and we will provide a better solution.

    0
  • The webhook option is what I was thinking would end up being the best tool.

    We do have a ticket created and are waiting for the reply, thank you for that.

    Just wanted to see if anyone has used Platform Events because this is the second request we have received for that internal object.

    Best,

    TJ

    0
  • We want to use platform events. 
    Are there templates avaible or examples from others?

    0

Please sign in to leave a comment.

 

Didn't find what you were looking for?

New post