• ArunBalaji K
  • 5 Points
  • Member since 2018

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 3

User-added image
global without sharing class GiveWorkThanksAction {

    @InvocableMethod(label='Give a Thanks Badge')
    global static void giveWorkBadgeActionsBatch(List<GiveWorkThanksRequest> requests) {
        for(GiveWorkThanksRequest request: requests){

    public static void giveWorkBadgeAction(GiveWorkThanksRequest request) {
        WorkThanks newWorkThanks = new WorkThanks();

                newWorkThanks.GiverId = request.giverId;
                newWorkThanks.Message = request.thanksMessage;
                newWorkThanks.OwnerId = request.giverId;

        insert newWorkThanks;

        WorkBadge newWorkBadge = new WorkBadge();

                // newWorkBadge.DefinitionId should be set to the ID for the Competitor Badge within this Org
                WorkBadgeDefinition workBadgeDef = [SELECT Id,Name FROM WorkBadgeDefinition WHERE Name = :request.badgeName Limit 1];

                newWorkBadge.DefinitionId = workBadgeDef.Id;
                newWorkBadge.RecipientId = request.receiverId;
                newWorkBadge.SourceId = newWorkThanks.Id ;
                //newWorkBadge.GiverId = request.giverId;

        insert newWorkBadge;

        WorkThanksShare newWorkThanksShare = new WorkThanksShare();

                newWorkThanksShare.ParentId = newWorkThanks.Id ;
                newWorkThanksShare.UserOrGroupId = request.receiverId;

                newWorkThanksShare.AccessLevel = 'Edit';
                insert newWorkThanksShare;

        FeedItem post = new FeedItem();

                post.ParentId = request.receiverId;
                post.CreatedById = request.giverId;
                post.Body = request.thanksMessage;
                post.RelatedRecordId = newWorkThanks.Id ;
                post.Type = 'RypplePost';

        insert post;


    global class GiveWorkThanksRequest {
        @InvocableVariable(label='Giver Id' required=true)
        global Id giverId;

        @InvocableVariable(label='Receiver Id' required=true)
        global Id receiverId;

        @InvocableVariable(label='Thanks Message' required=true)
        global String thanksMessage;

        @InvocableVariable(label='Badge Name' required=true)
        global String badgeName;
I get the following message:

Challenge Not yet complete... here's what's wrong: 
Couldn't find the "Thanks" badge in the instructor's Chatter feed after completing a Campaign.

According to my chatter feed:

User-added image

When I check the instructor's feed:

User-added image

Please advise.....
I am trying to complete "Automate Your Business Processes:  Build an Automated Workshop Management System: Automate Post-Workshop Tasks with Invocable Apex " and when I click "verify step" I get -
Challenge Not yet complete... here's what's wrong: 
Couldn't find the "Thanks" badge in the instructor's Chatter feed after completing a Campaign.

I have rebuilt the flow and the APEX and I can't get it to complete, but the "Thanks" badge IS in the insturctor's feed when I change the campaign to complete, so everything seems to work, I just cant get it to "verify"
I am in the last action where the process builder calls the invocable apex class. When i look for the class it appears with the LabelName
 'Give a Thanks Badge' and the lookups do not show up on the Giver Id and Receiver Id fields. Can someone tell me what am I doing wrong?
User-added image
If i put the apex class name as is shown in the trail it still does not find the Giver Id and Receiver Id values. My apex code has an active status.
User-added image
Thank you.