DocSF

DocSF

Did You Know?

We design Docy for the readers, optimizing not for page views or engagement

Send custom notification in Apex of Salesforce

Map<String, Schema.SObjectType> m  = Schema.getGlobalDescribe() ;
        Schema.SObjectType s = m.get('Account') ;
        Schema.DescribeSObjectResult r = s.getDescribe() ;
        String keyPrefix = r.getKeyPrefix();

        Map<String, Object> lightningPageRef = new Map<String, Object>{
            'type' => 'standard__namedPage',
            'attributes' => new Map<String, Object>{
                'pageName' => 'home'
            }
        };

Id typeId = '0ML1l00000001dxGAA';
        Messaging.CustomNotification notification = new Messaging.CustomNotification();
        notification.setTitle('test title');
        notification.setBody('test body');        
        notification.setSenderId(Userinfo.getUserId());
        notification.setNotificationTypeId(typeId );        
        notification.setTargetPageRef(JSON.serialize(lightningPageRef));
        notification.send(new Set<String> { Userinfo.getUserId() }); 

Related Post

I mercati emergenti del futuro

Entro il 2025 aggiungeranno complessivamente 4,3 miliar...

Salesforce change field view on list view rec

For most list views, your users can select which fields...

 I futures dell’Oro sono in ribasso d

Nel divisione Comex del New York Mercantile Exchange, ...

Leave a Comment