GithubHelp home page GithubHelp logo

chatterpostutilities's Introduction

Synopsis

ChatterPostUtilities is an APEX class I developed for making chatter post an easy way, by using this class you won't need to implement Salesforce's ConnectApi components, all you need here are strings.

Example

ChatterPostUtilities main method chatterPostFactoryBatchable receives a list of Map<Id, List<String>> so let's say you need a chatter post with no capabilities and you want the @mention to be located before the chatter post body, you only need to follow the example below, remember the chatter post body will be organized according to the order in which you add the strings in the map's list.

/* The code below will generate a chatter with no capabilities */

Id parentId; //This would be the chatter post parent record, it could be anything from a Sobject to a user's wall
List<Map<Id, List<String>>> result = New List<Map<Id, List<String>>>{
            new Map<Id, List<String>>{testAcct.Id => new List<String>{
                String.valueOf(userInfo.getUserId()), 'Test Post'}}
        };
        
ChatterPostUtilities.chatterPostFactoryBatchable(result, ChatterPostUtilities.CapabilityType.None);

/* The code below will generate a chatter post with a link capability */

Id parentId; //This would be the chatter post parent record, it could be anything from a Sobject to a user's wall
List<Map<Id, List<String>>> values = new List<Map<Id, List<String>>>{
new Map<Id, List<String>>{parentId => new List<String> {'Test Link', 'https://na14.salesforce.com/' + parentId}}};

ChatterPostUtilities.chatterPostFactoryBatchable(values, ChatterPostUtilities.CapabilityType.Link);

/* The code below will generate a chatter post with a Poll capability */

List<Map<Id, List<String>>> values = new List<Map<Id, List<String>>>{
new Map<Id, List<String>>{userInfo.getUserId() => new List<String> {'Do you like Salesforce?', 'Yes, I love it',
'No, I hate it'}}};

ChatterPostUtilities.chatterPostFactoryBatchable(values, ChatterPostUtilities.CapabilityType.Poll);

Motivation

Whenever I had to work with chatter posts I had to implement the same stuff so I decided I would write an utility class on which I have all chatter post related logic and components so I can re-use them, this class is intelligent enough to know when you're trying to @mention someone or you just wanna add a single string.

Installation

Just click the button below
Deploy to Salesforce

API Reference

ChatterPostUtilities contains the following public methods;

chatterPostFactoryBatchable(List<Map<Id, List<String>>> mChatterPostVals, CapabilityType capType)
createChatterPostComment(map<Id, List<String>> values)

//ChatterPostUtilities contains the following enum;

public enum CapabilityType {None, Link, Poll}

chatterpostutilities's People

Contributors

edguz0824 avatar

Stargazers

EdGuz avatar

Watchers

EdGuz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.