Skip to main content
Group

Apex SDK for Slack Beta

Previously named Foyer (UISF Apex) and Salesforce Slack SDK. A group for all members leading and partaking in the Slack UISF and/or Slack App Builder Pilots to ask questions and share feedback throughout the course of the pilot. Apex SDK for Slack beta documentation: https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/changelog.html Slack App Builder pilot documentation: See Files tab

Hi

I am facing an issue in creating YAML file in my VS Code. The requirement is to fetch Page Layout of a custom object in apex and use the field API names and Lables in YAML file (the one we create in .view file in viewdefinitions folder) to create a Record Create Form. 

I wrote the following code to return a List of key value pairs in apex.

 

    public static List<FieldData>  getHelpdeskLayout() {

        List<FieldData> fieldsList = new List<FieldData>();

        List<Metadata.Metadata> layouts = Metadata.Operations.retrieve(Metadata.MetadataType.Layout, new List<String> {'Helpdesk__c-Helpdesk Ticket Layout'});

        Metadata.Layout layoutMd = (Metadata.Layout)layouts.get(0);

        for (Metadata.LayoutSection section : layoutMd.layoutSections) {

            for (Metadata.LayoutColumn column : section.layoutColumns) {

                if (column.layoutItems != null) {

                    for (Metadata.LayoutItem item : column.layoutItems) {

                        System.debug(item);

                        Map<String, Schema.SObjectField> mfields = Schema.Helpdesk__c.SObjectType.getDescribe().fields.getMap();

                        Schema.DescribeFieldResult fieldResult = mfields.get(item.field).getDescribe();

                        System.debug('fieldResult.getLabel()  ' +fieldResult.getLabel());

                        System.debug('item.field  ' +item.field);

                        FieldData fieldData;

                        if(item.field =='Name')

                        {

                            fieldData = new FieldData(fieldResult.getLabel(), item.field,true,'textInput');

                        }

                        else{

                            fieldData = new FieldData(fieldResult.getLabel(), item.field,false,'textInput');

                        }

                        fieldsList.add(fieldData);                      

                    }

                }

            }

        }

        System.debug('fieldsList  ' +fieldsList);

        return fieldsList;    

    }

 

Note: FieldData is a wrapper class

global class FieldData {

    global String label;

    global Object value;

    global boolean isRequired;

    global String fieldType1;

    global FieldData(String label, Object value,boolean isRequired,String fieldType1) {

        this.label = label;

        this.value = value;

        this.isRequired = isRequired;

        this.fieldType1 = fieldType1;

    }

}

 

Following is the YAML file that I created 

description: "This component displays record details in a message"

schema:

  properties:

    headerText:

      type: string

      defaultValue: "Record Details"

dataproviders:

  record:

    definition: "apex__DataProviderSObjectRecord.getHelpdeskLayout"

components:

  - definition: modal

    properties:

      title: "Create Helpdesk Ticket"

      submitLabel: "Create"

    events:

      onsubmit:

        # definition maps to 'ActionDispatcherSubmitRecord' apex class implementing Slack.ActionDispatcher

        definition: "apex__action__ActionDispatcherSubmitRecord"

        properties:

          objectApiName: "Helpdesk__c"

    components:

      - definition: divider

      - definition: iteration

        properties:

          foreach: "{!record}"

          foritem: "record"

        components:

          - definition: input

            properties:

              label: "{!record.label}:"  # label is the field label

              required: "{!record.isRequired}"

            components:

              - definition: "{!record.fieldType1}"

                properties:

                  name: "{!record.value}"   # name should be FieldApiName

 

I get the error in apex saying "No component was found with definition {!record.fieldType1}"

My goal is to dynamically provide definition (textInput, Numer, datepicker, etc) in the iteration. I can't figure out what I am doing wrong here. 

8 answers
  1. May 28, 2024, 1:57 PM
    If the issue is that “Currently dynamically deciding the type is not supported via variables” - perhaps coding a repeating block in YAML with one of each component type and dynamically making just the appropriate one visible for each field to display using visibility property. Just a wild thought.
0/9000
0/9000

This feature has been in pilot/beta for over 3 years, with no updates.  I attempted to build an app and package it, only to find:    "Packaging is available in beta. Distribution of Slack Apps is available only after the beta phase is complete. Users operating under the beta agreement can't distribute Slack apps using the Apex SDK."  https://developer.salesforce.com/docs/platform/salesforce-slack-sdk/guide/packaging.html    I couldn't distribute it for installation into our production org. What's the point of this if we can't use it?   

4 answers
  1. Apr 29, 2025, 3:30 AM
    Hi all. At TDX25 TTTC session I raised this and Parker Harris stated it was still on the roadmap and definitely coming. Just no timeframe.
0/9000

I created a new view and added few fields on that and passing that view properties to apex for new record creation. If i am not wrong i have seen that 3000 is max length of the text input field on slack app's, and added 3000 as the max input for my fields on slack app view form. But when i tried to submit the form with max data in all the fields i am getting this error saying:  System.HandledException: Component contains too much action data. Must reduce length of event definitions or properties. And then i tried submitting the form with 2500 char's in all fields and kept trying it by bringing down the max length and when i gave 250 as max length for the input parameters it worked. So is there any alternative to this issue to fix or is this a limitation. 

2 answers
0/9000

Hi

I have been trying to set up Salesforce for Slack in my developer account connecting to Slack developer sandbox account. Things are fine with connection and I have a custom flow to send a message from Salesforce to slack using “send message” core action. It is posting link to the record but in slack it just appears as a link and does not unfurl into data and button as shown here.

HiI have been trying to set up Salesforce for Slack in my developer account connecting to Slack developer sandbox account.

Any suggestion on how to fix this?

CRUD layout and unfurl slack record layouts are working fine. When I post the same link manually as a user in slack, it works but when posted by the app “Salesforce for slack” by the flow it just remains as a link.

Thanks!

#Flow #Slack Basics #Slack Developers #Slack Community
0/9000

All - just in case there are still others in the group working with the SDK but suffering from the thin documentation and limited samples, I've been experimenting with ChatGPT to write me code samples of the Apex handlers. So far, so good. It sometimes defaults to writing against the Slack API, but you just need to gently remind it that you want code using the Apex SDK classes.  An example - 

 

I prompted: "When using the Apex SDK for Slack (Beta), write me an Action Dispatcher class that when called from a message view in a users channel, it will update the original message in their feed when invoked."

 

When it came back with API code, I simply nudged it..."Instead of coding to the Slack API, please use the Apex Slack SDK classes to do the same thing."  - and it did.

 

Give it a try and lemme know. 

1 comment
  1. Nov 24, 2024, 3:58 AM
    Further on this. What’s interesting is that depending on how specific the prompt, ChatGpT may still hallucinate so be very careful. It’s quite intermittent in delivering correct code content.
0/9000

I’ve been exploring and building with the Slack Apex SDK for well over a year, ever since it went into live Beta. I suspect those in this group know it’s a great framework and allows for both simple and complex custom features for integrating Slack with a Salesforce org without the need for an intermediate web app. I’ve post an IdeaExchange get it over the hump to GA. If you agree, please upvote me. Here’s a link:

https://ideas.salesforce.com/s/idea/a0B8W00000QenUPUAZ/release-the-slack-apex-sdk-in-ga#Salesforce Developer
0/9000

Hi, I am trying to post a screen flow(multiple screens) to to be run in slack on click of a button using the Slack screen Flow functionality. The multiple screen flow was working fine till march 31st,2024 but now the flow finishes after the first screen. What has changed? why I am not able to navigate through multiple screens now?

Please help.

0/9000

While starting the slack app created using Apex SDK for slack, the app does not start and just says that This is still a work in progress.

The configurations have been done as per the setup advised on documentation.

Along this line I would also like to ask, that the slackapp metadata in the project stores the configurational information as to where the salesforce code is sending data.

But where in the slack app defined using slack api manifest file do we store as to where the slack app is connected to, which org, which user.

Any help would be much appreciated here

2 answers
  1. Jun 14, 2023, 2:59 PM
    Gaurav - my rudimentary understanding is that the info regarding which org is connected is not available to us. The key seems to be the Application ID that we take from the Slack manifest and with the Property in the SlackApp meta xml of the project as deployed into an org. The urls to Foyer delegate all to behind the scenes connections for routing to the org with that metadata defined.
0/9000